Created
December 26, 2013 13:50
-
-
Save muayyad-alsadi/8134064 to your computer and use it in GitHub Desktop.
listView with onclick
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static class MyViewHolder { ImageView logo; TextView name, foo, bar;} | |
public View getView (int position, View v, ViewGroup parent) { | |
MyType item=getItem(position); | |
MyViewHolder holder; | |
if (v==null) { | |
v = adapter.inflater.inflate(R.layout.my_row, null, false); | |
holder = new MyViewHolder(); | |
holder.logo=(ImageView) v.findViewById(R.id.logo); | |
holder.name=(TextView) v.findViewById(R.id.name); | |
v.setTag(holder); | |
} else { | |
holder = (MyViewHolder) v.getTag(); | |
} | |
holder.name.setText(item.name); | |
} | |
// ---------- | |
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { | |
@Override | |
public void onItemClick(AdapterView<?> parent, final View view, | |
int pos, long id) { | |
MyType item=adapter.getItem(pos); | |
MyActivity.onItemClicked(pos, item); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment