/ / प्रत्येक तत्व के लिए संपादन टेक्स्ट और चेकबॉक्स के साथ एंड्रॉइड लिस्टव्यू - एंड्रॉइड, लिस्टव्यू, एंड्रॉइड-एडिटेक्स्ट, एंड्रॉइड-चेकबॉक्स

प्रत्येक तत्व के लिए संपादन टेक्स्ट और चेकबॉक्स के साथ एंड्रॉइड लिस्टव्यू - एंड्रॉइड, लिस्टव्यू, एंड्रॉइड-एडिटेक्स्ट, एंड्रॉइड-चेकबॉक्स

मान लें कि मेरे पास वस्तुओं की एक सूची है और मैं चाहता हूंइन वस्तुओं में से प्रत्येक के साथ एक फार्म बनाने के लिए। इस फ़ॉर्म में दो चेकबॉक्स और एक संपादन टेक्स्ट शामिल है। उदाहरण के लिए मैं जानना चाहता हूं कि प्रत्येक आइटम गोदाम और इसकी मात्रा में मौजूद है या नहीं। मैं एक सूचीदृश्य का उपयोग करने के लिए अपनी समस्या को हल करने के लिए सोच रहा हूं, जहां मेरी सूचीदृश्य के प्रत्येक तत्व में एक आइटम, दो चेकबॉक्स और एक संपादन टेक्स्ट का नाम शामिल होगा।
समस्या यह है कि सूचीदृश्य का एकमात्र उपयोग मैं तत्वों की सूची प्रस्तुत करना जानता हूं, मैं इसके साथ अपनी समस्या को हल करने के लिए नहीं हूं (मैं "एंड्रॉइड में एक शुरुआतकर्ता हूं)। क्या कोई मेरी मदत कर सकता है ?
क्या मेरी समस्या को हल करने का कोई और तरीका है?
धन्यवाद

उत्तर:

जवाब के लिए 0 № 1

एक Cusom ListView एडाप्टर लागू करने का प्रयास करें! यह आपके विचार से आसान है!

सबसे पहले आपको लेआउट बनाना होगा जो आपकी सूची में प्रत्येक आइटम का प्रतिनिधित्व करेगा:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test TEST" />

<LinearLayout android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignBottom="@id/itemTextView"
android:layout_alignParentRight="true">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/doneCheckBox" />
</LinearLayout>

फिर अपने कोड के अंदर क्यूसम एडाप्टर लागू करें:

public CusomAdapter(Context mainContex, YourItems<SomeItem> someItems) {
this.mainContex = mainContex;
this.someItems = someItems;
}

@Override
public int getCount() {
return someItems.size();
}

@Override
public Object getItem(int position) {
return someItems.get(position);
}

@Override
public long getItemId(int position) {
return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {


View item = convertView;
if (item == null) {
item = LayoutInflater.from(mainContex).inflate(R.layout.shoplist_item, null); // your listView layout here!
}

//fill listView item with your data here!
//initiate your check box
CheckBox doneCheckBox = (CheckBox)item.findViewById(R.id.doneCheckBox);

//add a checkbox listener
doneCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked){
doneCheckBox.ischecked=true;
}
else{
doneCheckBox.ischecked=false;
}
}
});

return item;
}

अपने गतिविधि लेआउट के अंदर ListView तत्व जोड़ने के लिए मत भूलना!