i am creating an application in which data is got from a barcode scanner which identifies from an id, and show detail from the database through a web service. i am currently using custom list which has a text view and a button, the data which i want to embed on the textview is displaying correctly...
my question is how do i delete a particular row from the list on the button click .
here is the custom adaptor code.
public class MyCustomAdapter extends ArrayAdapter<String>
{
public MyCustomAdapter(Context context, int textViewResourceId, ArrayList<String> items)
{
super(context, textViewResourceId, items);
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
LayoutInflater inflater = FusionMain.this.getLayoutInflater();
View row = inflater.inflate(R.layout.list_row, parent, false);
return row;
}
} // end MyCustomAdapter
what other function should i be creating in custom adapter ? i am new in android development.. if you need further more detail i can update the question or the code. kindly respond
The main idea of the adapter is that you pass ArrayList items to it and they will be shown on the AdapterView.
getView method with position parameter will be run for each element currently shown on the list. When you scroll the list you will get more getView() calls. From getView method you have to return a view that will be shown on the list but it already has to be filled with DATA! for example:
When you want the list to be changed you have to change the items object (for example remove single item from this ArrayList) and then you have to use
myAdapter.notifyDatasetChanged()
method. This will make your AdapterView (eg ListView) to update one more time and call getView method for all visible positions one more time.