Reputation: 137
I created a modified ListView, in order to display various information on the screen. Now I want to perform an individual action on the View the user has clicked, like making it invisible.
I tried something, but it doesn't seem to work properly. It makes each of the 4 views invisible, instead of just 1.
public class affichageListViewAdapter extends BaseAdapter {
public void actionC(){
ListListView.get(0).test();
}
// some more code ...
}
public class affichageListView extends LinearLayout {
// some more code ...
public void test(){
textViewTest.setVisibility(GONE);
}
}
public class listeVideo extends ListFragment{
private affichageListViewAdapter adapter;
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
adapter.test();
}
}
public class affichageListView extends LinearLayout {
private TextView mTextView;
public affichageListView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
public affichageListView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public affichageListView(Context context) {
super(context);
init();
}
private void init() {
inflate(getContext(), R.layout.affichafe_list_view, this);
mTextView = (TextView) findViewById(R.id.textViewTitre);
}
}
Upvotes: 0
Views: 72
Reputation: 3268
I purpose you should have an array element of boolean in your adapter, with every. Then, add this method in your adapter:
public void hideItem(int position){
positionsToShow.get(position) = false;
notifyDataSetChanged();
}
public void showItem(int position){
positionsToShow.get(position) = true;
notifyDataSetChanged();
}
And in your getView you should put:
if(!positionsToShow.get(position)){
//textView.setVisibility(View.INVISIBLE);
}
Upvotes: 1