Re: [android-developers] how to get focus(selection) to listactivity?
hi,
i have tried this from sdk examples.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state.
-->
<item android:state_focused="true" android:state_enabled="false" android:state_pressed="true" android:drawable="@drawable/list_selector_background_disabled" />
<item android:state_focused="true" android:state_enabled="false" android:drawable="@drawable/list_selector_background_disabled" />
<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition" />
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition" />
<item android:state_focused="true" android:drawable="@drawable/list_selector_background_focus" />
</selector>
and this is my adapter class.
private class OrderAdapter extends BaseAdapter implements OnClickListener
{
private LayoutInflater mInflater;
public OrderAdapter(Context context)
{
mInflater = LayoutInflater.from(context);
}
/**
* @todo Get view and set it into listview row
* @author virtueinfo
* @access public
* @param int position, View convertView, ViewGroup parent
*/
public View getView(int position, View convertView, ViewGroup parent)
{
ViewHolder holder;
// Here if condition check view is null or not. If view is null then it will inflate
// album row and initialize it, otherwise it will get tag and assign it to holder.
if (convertView == null)
{
convertView = mInflater.inflate(R.layout.albumrow, null);
holder = new ViewHolder();
holder.txtAlbumName = (TextView) convertView.findViewById(R.id.txtAlbumName);
holder.txtArtistName = (TextView) convertView.findViewById(R.id.txtArtistName);
holder.imgAlbumArt = (ImageView)convertView.findViewById(R.id.imgAlbumArt);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder) convertView.getTag();
}
holder.txtAlbumName.setText("texthere");
holder.txtArtistName.setText("texthere");
convertView.setOnClickListener(new OnItemClickListener(position));
return convertView;
}
public class ViewHolder
{
public TextView txtAlbumName, txtArtistName;
public ImageView imgAlbumArt;
}
public int getCount(){return Utility.seperateAlbum.size();}
public Object getItem(int position){return position;}
public long getItemId(int position){return position;}
public void onClick(View v){}
}
is there something i am missing?
--
Regards,
Hitendrasinh Gohil
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home