मैं "निम्नलिखित मैच" एप्लिकेशन विकसित कर रहा हूं। आवेदन के लिए प्रयुक्त एक्सएमएल निम्नानुसार है:एंड्रॉइड: प्रोग्रामिंग के रूप में ग्रिडलाउट [ग्रिड व्यू नहीं] कैसे बनाएं?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/lytLinear"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/txtQuestion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="30dp"
android:text="Match the following questions with their answers." />
<GridLayout
android:id="@+id/lytGrid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="3"
android:columnWidth="300dp"
android:orientation="vertical"
android:rowCount="5"
android:stretchMode="columnWidth" >
<LinearLayout
android:id="@+id/Q1Lyt"
android:layout_width="160dp"
android:layout_height="50dp"
android:layout_column="0"
android:layout_row="0"
android:background="@drawable/shape_qn"
android:gravity="center" >
<TextView
android:id="@+id/Q1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_row="0"
android:text="Question1" />
</LinearLayout>
<LinearLayout
android:id="@+id/A1Lyt"
android:layout_width="160dp"
android:layout_height="50dp"
android:layout_column="1"
android:layout_row="0"
android:background="@drawable/shape"
android:gravity="center"
android:text="Answer1" >
<TextView
android:id="@+id/A1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_row="0"
android:text="Answer1" />
</LinearLayout>
<LinearLayout
android:id="@+id/Q2Lyt"
android:layout_width="160dp"
android:layout_height="50dp"
android:layout_column="0"
android:layout_row="1"
android:background="@drawable/shape_qn"
android:gravity="center" >
<TextView
android:id="@+id/Q2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Question2" />
</LinearLayout>
<LinearLayout
android:id="@+id/A2Lyt"
android:layout_width="160dp"
android:layout_height="50dp"
android:layout_column="1"
android:layout_row="1"
android:background="@drawable/shape"
android:gravity="center" >
<TextView
android:id="@+id/A2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_row="0"
android:text="Answer2" />
</LinearLayout>
</GridLayout>
</LinearLayout>
मैंने ग्रिड लेआउट बनाने के लिए निम्न कोड का प्रयास किया है। हालांकि, बच्चे रैखिक लेआउट के लिए, मैं प्रोग्रामेटिक रूप से एंड्रॉइड सेट करने का कोई तरीका नहीं ढूंढ पा रहा हूं: layout_column और android: layout_row पैरामीटर।
GridLayout gridLayout = new GridLayout(this);
gridLayout.setColumnCount(2);
gridLayout.setRowCount(15);
LinearLayout lyt1 = new LinearLayout(this);
LinearLayout.LayoutParams prmsLinLyt = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
कोई पॉइंटर्स?
मैं और जानकारी खोदने में सक्षम नहीं हूं। इसलिए, मैं इसके बजाय एक टेबल लेआउट का उपयोग कर रहा हूँ। – Srikanth
मुझे यह नहीं पता कि यह सवाल क्यों बंद कर दिया गया है। मुझे लगता है कि यह एक त्रुटि है। अगर प्रश्न का उत्तर दिया गया तो इससे मेरी मदद की होगी। – Softlion
var gridLayout पैराम्स = नया ग्रिडलाउटआउट .आउटआउट(); ग्रिडलायआउट पैराम्स। सेग ग्रेविटी (ग्रेविटीफ्लैग्स। भरें); ग्रिडलायआउट पैराम्स। RowSpec = GridLayout.InvokeSpec (iRow, 1); ग्रिडलायआउट पैराम्स। कॉलमस्पेक = ग्रिडलाउट। इन्वोकस्पेक (आईकॉल, 1); ग्रिड। एडव्यू (एवी व्यू, ग्रिडलायआउट पैराम्स); – Softlion