I am trying to add an viewSwicther to a listview. What I want is that when an item is clicked for a long time, that field will be transformed to an EditText. At the moment it's always the element at the top of the list that tranforms from TextView to EditText. I have a custom adapter based on an baseAdapter.
The code is shown below;
listView.setOnItemLongClickListener(new OnItemLongClickListener(){
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
int size = findSizeOfArray();
if(position == (size-1)){
ViewSwitcher switcher = (ViewSwitcher)findViewById(R.id.my_switcher);
switcher.showNext();
preAdapter.notifyDataSetChanged();
}
return true;
}
});
preAdapter.notifyDataSetChanged();
I think you had to find and set your LongClick position as you did but you should pass this position to your Custom Adapter , then inside your Custom Adapter you catch this position and set a GlobalVariable to hold your selection Position , then in
getView()
function you can check that if getView() related position is equal to your Selected position which you receive from your Main Activity , then you can implement yourViewSwitcher
inside of your ListgetView()
function