/ / editTextと各要素のチェックボックスを備えたAndroidリストビュー-android、listview、android-edittext、android-checkbox

アンドロイド、リストビュー、android-edittext、android-checkboxの各要素のeditTextとcheckboxのAndroidリストビュー

「アイテムのリストがあり、欲しいこれらの各アイテムでフォームを構築します。このフォームは、2つのチェックボックスとeditTextで構成されています。たとえば、各アイテムが倉庫にあるかどうかとその数量を知りたいです。私は、リストビューの各要素がアイテムの名前、2つのチェックボックス、およびeditTextで構成されるリストビューを使用して問題を解決することを考えています。
問題は、リストビューの唯一の使用が要素のリストを提示することを知っているということです。それで問題を解決する方法はありません(アンドロイドの初心者です)。誰か助けてくれますか?
私の問題を解決する別の方法はありますか?
ありがとうございました

回答:

回答№1は0

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>

次に、コード内にcusomアダプターを実装します。

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要素を追加することを忘れないでください!