My idea is to do a shopping list and when i click on an item it gets a strikethrough and goes to the end of the list. So far i have gotten everything except sending the item to the end of the list. Here is a bit of my code:
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
TextView text = (TextView) v.findViewById(android.R.id.text1);
text.setPaintFlags(text.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
Edit:
Thank you for the anwsers so far. Some helpful people requested more code so here is everything (including adding stuff to list):
public class ShoppingActivity extends ListActivity {
ArrayList<String> list = new ArrayList<String>();
ArrayAdapter<String> adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shopping);
Button add = (Button) findViewById(R.id.btnAdd);
adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, list);
OnClickListener listner = new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
EditText item = (EditText) findViewById(R.id.etItem);
list.add(item.getText().toString());
item.setText("");
adapter.notifyDataSetChanged();
}
};
add.setOnClickListener(listner);
setListAdapter(adapter);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
TextView text = (TextView) v.findViewById(android.R.id.text1);
text.setPaintFlags(text.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
}