how to create trackballevent in android custom adapter?
Posted
by UMMA
on Stack Overflow
See other posts from Stack Overflow
or by UMMA
Published on 2010-05-12T10:28:52Z
Indexed on
2010/05/12
10:34 UTC
Read the original article
Hit count: 292
dear friends,
i am using following code to create custom adapter for listview. now i want to use trackball click event in it but i dont know how to do that can any one help me out in creating ontracballevent in custom adapter? i have tried writing few lines but not able to solve it.
public class EfficientAdapter extends BaseAdapter implements Filterable {
private LayoutInflater mInflater;
private Context context;
int pos;
public EfficientAdapter(Context context) {
mInflater = LayoutInflater.from(context);
this.context = context;
}
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
convertView = mInflater.inflate(R.layout.adaptor_contentposts, null);
convertView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//click functionality } });
MotionEvent event= MotionEvent.CREATOR.createFromParcel(null);
switch (event.getAction())
{
case MotionEvent.ACTION_DOWN:
//display click message
}
convertView.onTrackballEvent(event);
return convertView;
}
class ViewHolder {
TextView textLine;
TextView textLine2;
TextView PostedByAndPostedOn;
ImageButton ImgButton;
}
@Override
public Filter getFilter() {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public int getCount() {
return ad_id.length;
}
@Override
public Object getItem(int position) {
return ad_id[position];
}
}
© Stack Overflow or respective owner