I have a custom table cell which basically has 2 buttons, one textview and one edit text. Next to each edit text there is a plus and minus button. Effectively to increment / decrement the number in the text box.
I can't work out how I link the buttons to the right text box. I.e. when I press plus, have a routine that only works for the edittext box in it's row. Do I have to set a custom ID for each text box?
I have all the text coming out correctly for the questions.
My custom cell is:
<TextView
android:id="@+id/txtOption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_weight="0.00"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/btnPlus"
style="?android:attr/buttonStyleSmall"
android:layout_width="49dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/txtOption"
android:layout_weight="0.00"
android:text="+" />
<Button
android:id="@+id/btnMinus"
style="?android:attr/buttonStyleSmall"
android:layout_width="49dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btnPlus"
android:layout_alignBottom="@+id/btnPlus"
android:layout_toRightOf="@+id/btnPlus"
android:layout_weight="0.00"
android:text="-" />
<EditText
android:id="@+id/tbAnswer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/btnMinus"
android:layout_toRightOf="@+id/btnMinus"
android:ems="10"
android:inputType="number" >
<requestFocus />
</EditText>
My custom cell is being called with:
class CustomAdapter extends BaseAdapter
{
@Override
public int getCount() {
return mDescription.size();
}
@Override
public Object getItem(int arg0) {
return null;
}
@Override
public long getItemId(int arg0) {
return 0;
}
@Override
public View getView(int arg0, View arg1, ViewGroup arg2) {
LayoutInflater inf=getLayoutInflater();
View v=inf.inflate(R.layout.noncriticalasset, arg2,false);
Button btPlus=(Button)v.findViewById(R.id.btnPlus);
Button btMinus=(Button)v.findViewById(R.id.btnMinus);
TextView tv=(TextView)v.findViewById(R.id.txtOption);
EditText et=(EditText)v.findViewById(R.id.tbAnswer);
tv.setText(mDescription.get(arg0).toString());
return v;
}
}
I will also have to collate all the information from all of the textboxes afterwards and write one query for each. Do I have a submit button that does a for each? (Is there an auto array created or similar?)
Tom