I have a listview and each row contains a textview and an edittext. I also have a button below the listview where i want to access only the edittext widget of all the rows of the listview. Can anybody help me ?
HexList Layout : This is my main listview which contains custom rows. And below the main list view i have a button "save as". On clicking the button i want to access the edittext of each and every row. I am confused about the class to be used to get the edittext widget, i.e. listview or the adapter for the listview.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="@+id/listViewHex1"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_above="@+id/saveButton1"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" >
</ListView>
<Button
android:id="@+id/saveButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:text="@string/save" />
</RelativeLayout>
HexRow Layout: This is my custum row for the listview, which contains a textview and an edittext.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/hexrowlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/hexEditTextRow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textShortMessage" >
<requestFocus />
</EditText>
<TextView
android:id="@+id/hexTextViewRow"
android:layout_width="match_parent"
android:layout_height="30dp" />
</LinearLayout>
In the main activity iam trying to access the edittext of each and evry row.
Button saveToFile = (Button) findViewById(R.id.saveButton1);
saveToFile.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
// Saving hexcode button names from edittext into vitaminslist
{
int size = aa.getCount();
for(int i = 0; i < size; i++){
//benefits.getChi
EditText e = (EditText) aa.getView(i, benefits, null);
HexCode he = vitaminsList.get(i);
he.setName(e.getText().toString());
}
}
}
});