[android-developers] listView: how to add text view on top of the list
*am making a list by this code* public class myList extends ListActivity{ private static EfficientAdapter efficientAdapter; private static class EfficientAdapter extends BaseAdapter { static Bitmap bmp[] = new Bitmap[3]; private LayoutInflater mInflater; public EfficientAdapter(Context context) { mInflater = LayoutInflater.from(context); bmp[1] = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon1); bmp[2] = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon2); bmp[3] = BitmapFactory.decodeResource(context.getResources(),R.drawable.icon3); } public int getCount() { return DATA.length; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } iew(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(R.layout.mainscreen, null); holder = new ViewHolder(); holder.text = (TextView) convertView.findViewById(R.id.label); holder.icon = (ImageView) convertView.findViewById(R.id.icon); holder.text.setGravity(Gravity.CENTER_VERTICAL); holder.text.setHeight(64); holder.icon.setMinimumHeight(64); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.text.setText(DATA[position]); holder.icon.setImageBitmap((bmp[position])); return convertView; } static class ViewHolder { TextView text; ImageView icon; } } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); efficientAdapter = new EfficientAdapter(this); setListAdapter(efficientAdapter); * and want to add a text view on the top of list...but it should not be the list item* -- A N K ! T.. -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] listView: how to add text view on top of the list
If you want it to scroll with the list, use addHeaderView(). If you do not want it to scroll with the list, put it above the ListView using a LinearLayout or RelativeLayout. On Fri, Sep 3, 2010 at 8:28 AM, A N K ! T ankit.awasth...@gmail.com wrote: am making a list by this code public class myList extends ListActivity{ private static EfficientAdapter efficientAdapter; private static class EfficientAdapter extends BaseAdapter { static Bitmap bmp[] = new Bitmap[3]; private LayoutInflater mInflater; public EfficientAdapter(Context context) { mInflater = LayoutInflater.from(context); bmp[1] = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon1); bmp[2] = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon2); bmp[3] = BitmapFactory.decodeResource(context.getResources(),R.drawable.icon3); } public int getCount() { return DATA.length; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } iew(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(R.layout.mainscreen, null); holder = new ViewHolder(); holder.text = (TextView) convertView.findViewById(R.id.label); holder.icon = (ImageView) convertView.findViewById(R.id.icon); holder.text.setGravity(Gravity.CENTER_VERTICAL); holder.text.setHeight(64); holder.icon.setMinimumHeight(64); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.text.setText(DATA[position]); holder.icon.setImageBitmap((bmp[position])); return convertView; } static class ViewHolder { TextView text; ImageView icon; } } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); efficientAdapter = new EfficientAdapter(this); setListAdapter(efficientAdapter); and want to add a text view on the top of list...but it should not be the list item -- A N K ! T.. -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to Android Development_ Version 3.1 Available! -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] listView: how to add text view on top of the list
but how where to write it layout code is LinearLayout xmlns:android=http://schemas.android.com/apk/res/android; android:layout_height=wrap_content android:layout_width=fill_parent ImageView android:id=@+id/icon android:layout_width=40sp android:layout_height=wrap_content android:src=@drawable/on android:visibility=visible/ TextView android:id=@+id/label android:layout_width=wrap_content android:layout_height=wrap_content android:textSize=20sp/ /LinearLayout On Fri, Sep 3, 2010 at 6:00 PM, Mark Murphy mmur...@commonsware.com wrote: If you want it to scroll with the list, use addHeaderView(). If you do not want it to scroll with the list, put it above the ListView using a LinearLayout or RelativeLayout. On Fri, Sep 3, 2010 at 8:28 AM, A N K ! T ankit.awasth...@gmail.com wrote: am making a list by this code public class myList extends ListActivity{ private static EfficientAdapter efficientAdapter; private static class EfficientAdapter extends BaseAdapter { static Bitmap bmp[] = new Bitmap[3]; private LayoutInflater mInflater; public EfficientAdapter(Context context) { mInflater = LayoutInflater.from(context); bmp[1] = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon1); bmp[2] = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon2); bmp[3] = BitmapFactory.decodeResource(context.getResources(),R.drawable.icon3); } public int getCount() { return DATA.length; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } iew(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(R.layout.mainscreen, null); holder = new ViewHolder(); holder.text = (TextView) convertView.findViewById(R.id.label); holder.icon = (ImageView) convertView.findViewById(R.id.icon); holder.text.setGravity(Gravity.CENTER_VERTICAL); holder.text.setHeight(64); holder.icon.setMinimumHeight(64); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.text.setText(DATA[position]); holder.icon.setImageBitmap((bmp[position])); return convertView; } static class ViewHolder { TextView text; ImageView icon; } } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); efficientAdapter = new EfficientAdapter(this); setListAdapter(efficientAdapter); and want to add a text view on the top of list...but it should not be the list item -- A N K ! T.. -- 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+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to Android Development_ Version 3.1 Available! -- 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+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- A N K ! T.. -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] listView: how to add text view on top of the list
You need to change the .java code.. no xml... hm.. when i come back to home, i review your. Franklin Masao Hirata 6365-3650 / 4787-5360 GoogleAndroid's developers 2010 All programmers are playwrights and all computers are lousy actors. From: A N K ! T ankit.awasth...@gmail.com To: android-developers@googlegroups.com Sent: Fri, September 3, 2010 9:56:33 AM Subject: Re: [android-developers] listView: how to add text view on top of the list but how where to write it layout code is LinearLayout xmlns:android=http://schemas.android.com/apk/res/android; android:layout_height=wrap_content android:layout_width=fill_parent ImageView android:id=@+id/icon android:layout_width=40sp android:layout_height=wrap_content android:src=@drawable/on android:visibility=visible/ TextView android:id=@+id/label android:layout_width=wrap_content android:layout_height=wrap_content android:textSize=20sp/ /LinearLayout On Fri, Sep 3, 2010 at 6:00 PM, Mark Murphy mmur...@commonsware.com wrote: If you want it to scroll with the list, use addHeaderView(). If you do not want it to scroll with the list, put it above the ListView using a LinearLayout or RelativeLayout. On Fri, Sep 3, 2010 at 8:28 AM, A N K ! T ankit.awasth...@gmail.com wrote: am making a list by this code public class myList extends ListActivity{ private static EfficientAdapter efficientAdapter; private static class EfficientAdapter extends BaseAdapter { static Bitmap bmp[] = new Bitmap[3]; private LayoutInflater mInflater; public EfficientAdapter(Context context) { mInflater = LayoutInflater.from(context); bmp[1] = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon1); bmp[2] = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon2); bmp[3] = BitmapFactory.decodeResource(context.getResources(),R.drawable.icon3); } public int getCount() { return DATA.length; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } iew(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(R.layout.mainscreen, null); holder = new ViewHolder(); holder.text = (TextView) convertView.findViewById(R.id.label); holder.icon = (ImageView) convertView.findViewById(R.id.icon); holder.text.setGravity(Gravity.CENTER_VERTICAL); holder.text.setHeight(64); holder.icon.setMinimumHeight(64); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.text.setText(DATA[position]); holder.icon.setImageBitmap((bmp[position])); return convertView; } static class ViewHolder { TextView text; ImageView icon; } } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); efficientAdapter = new EfficientAdapter(this); setListAdapter(efficientAdapter); and want to add a text view on the top of list...but it should not be the list item -- A N K ! T.. -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to Android Development_ Version 3.1 Available! -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- A N K ! T.. -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You
Re: [android-developers] listView: how to add text view on top of the list
Hello Ankit, Thanks for this. Its working. Thanks very much. Regards/Thanks, Dhrumil On Fri, Sep 3, 2010 at 6:26 PM, A N K ! T ankit.awasth...@gmail.com wrote: but how where to write it layout code is LinearLayout xmlns:android=http://schemas.android.com/apk/res/android; android:layout_height=wrap_content android:layout_width=fill_parent ImageView android:id=@+id/icon android:layout_width=40sp android:layout_height=wrap_content android:src=@drawable/on android:visibility=visible/ TextView android:id=@+id/label android:layout_width=wrap_content android:layout_height=wrap_content android:textSize=20sp/ /LinearLayout On Fri, Sep 3, 2010 at 6:00 PM, Mark Murphy mmur...@commonsware.comwrote: If you want it to scroll with the list, use addHeaderView(). If you do not want it to scroll with the list, put it above the ListView using a LinearLayout or RelativeLayout. On Fri, Sep 3, 2010 at 8:28 AM, A N K ! T ankit.awasth...@gmail.com wrote: am making a list by this code public class myList extends ListActivity{ private static EfficientAdapter efficientAdapter; private static class EfficientAdapter extends BaseAdapter { static Bitmap bmp[] = new Bitmap[3]; private LayoutInflater mInflater; public EfficientAdapter(Context context) { mInflater = LayoutInflater.from(context); bmp[1] = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon1); bmp[2] = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon2); bmp[3] = BitmapFactory.decodeResource(context.getResources(),R.drawable.icon3); } public int getCount() { return DATA.length; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } iew(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(R.layout.mainscreen, null); holder = new ViewHolder(); holder.text = (TextView) convertView.findViewById(R.id.label); holder.icon = (ImageView) convertView.findViewById(R.id.icon); holder.text.setGravity(Gravity.CENTER_VERTICAL); holder.text.setHeight(64); holder.icon.setMinimumHeight(64); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.text.setText(DATA[position]); holder.icon.setImageBitmap((bmp[position])); return convertView; } static class ViewHolder { TextView text; ImageView icon; } } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); efficientAdapter = new EfficientAdapter(this); setListAdapter(efficientAdapter); and want to add a text view on the top of list...but it should not be the list item -- A N K ! T.. -- 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+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to Android Development_ Version 3.1 Available! -- 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+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- A N K ! T.. -- 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+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are
Re: [android-developers] listView: how to add text view on top of the list
There is no ListView in this layout. Hence, this is not the correct layout. Here is a sample project showing a ListView with a TextView above it: http://github.com/commonsguy/cw-android/tree/master/Selection/List/ On Fri, Sep 3, 2010 at 8:56 AM, A N K ! T ankit.awasth...@gmail.com wrote: but how where to write it layout code is LinearLayout xmlns:android=http://schemas.android.com/apk/res/android; android:layout_height=wrap_content android:layout_width=fill_parent ImageView android:id=@+id/icon android:layout_width=40sp android:layout_height=wrap_content android:src=@drawable/on android:visibility=visible/ TextView android:id=@+id/label android:layout_width=wrap_content android:layout_height=wrap_content android:textSize=20sp/ /LinearLayout On Fri, Sep 3, 2010 at 6:00 PM, Mark Murphy mmur...@commonsware.com wrote: If you want it to scroll with the list, use addHeaderView(). If you do not want it to scroll with the list, put it above the ListView using a LinearLayout or RelativeLayout. On Fri, Sep 3, 2010 at 8:28 AM, A N K ! T ankit.awasth...@gmail.com wrote: am making a list by this code public class myList extends ListActivity{ private static EfficientAdapter efficientAdapter; private static class EfficientAdapter extends BaseAdapter { static Bitmap bmp[] = new Bitmap[3]; private LayoutInflater mInflater; public EfficientAdapter(Context context) { mInflater = LayoutInflater.from(context); bmp[1] = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon1); bmp[2] = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon2); bmp[3] = BitmapFactory.decodeResource(context.getResources(),R.drawable.icon3); } public int getCount() { return DATA.length; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } iew(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(R.layout.mainscreen, null); holder = new ViewHolder(); holder.text = (TextView) convertView.findViewById(R.id.label); holder.icon = (ImageView) convertView.findViewById(R.id.icon); holder.text.setGravity(Gravity.CENTER_VERTICAL); holder.text.setHeight(64); holder.icon.setMinimumHeight(64); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.text.setText(DATA[position]); holder.icon.setImageBitmap((bmp[position])); return convertView; } static class ViewHolder { TextView text; ImageView icon; } } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); efficientAdapter = new EfficientAdapter(this); setListAdapter(efficientAdapter); and want to add a text view on the top of list...but it should not be the list item -- A N K ! T.. -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to Android Development_ Version 3.1 Available! -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- A N K ! T.. -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy) http://commonsware.com |
Re: [android-developers] listView: how to add text view on top of the list
@ Franklin Thanks i ll wait... @ Mark i need to just put some code in my java file... xml is right.. i am creating list adapter though subclass i.e efficient adapter... so tell me sone java code for that.. thanks On Fri, Sep 3, 2010 at 6:34 PM, Mark Murphy mmur...@commonsware.com wrote: There is no ListView in this layout. Hence, this is not the correct layout. Here is a sample project showing a ListView with a TextView above it: http://github.com/commonsguy/cw-android/tree/master/Selection/List/ On Fri, Sep 3, 2010 at 8:56 AM, A N K ! T ankit.awasth...@gmail.com wrote: but how where to write it layout code is LinearLayout xmlns:android=http://schemas.android.com/apk/res/android; android:layout_height=wrap_content android:layout_width=fill_parent ImageView android:id=@+id/icon android:layout_width=40sp android:layout_height=wrap_content android:src=@drawable/on android:visibility=visible/ TextView android:id=@+id/label android:layout_width=wrap_content android:layout_height=wrap_content android:textSize=20sp/ /LinearLayout On Fri, Sep 3, 2010 at 6:00 PM, Mark Murphy mmur...@commonsware.com wrote: If you want it to scroll with the list, use addHeaderView(). If you do not want it to scroll with the list, put it above the ListView using a LinearLayout or RelativeLayout. On Fri, Sep 3, 2010 at 8:28 AM, A N K ! T ankit.awasth...@gmail.com wrote: am making a list by this code public class myList extends ListActivity{ private static EfficientAdapter efficientAdapter; private static class EfficientAdapter extends BaseAdapter { static Bitmap bmp[] = new Bitmap[3]; private LayoutInflater mInflater; public EfficientAdapter(Context context) { mInflater = LayoutInflater.from(context); bmp[1] = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon1); bmp[2] = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon2); bmp[3] = BitmapFactory.decodeResource(context.getResources(),R.drawable.icon3); } public int getCount() { return DATA.length; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } iew(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(R.layout.mainscreen, null); holder = new ViewHolder(); holder.text = (TextView) convertView.findViewById(R.id.label); holder.icon = (ImageView) convertView.findViewById(R.id.icon); holder.text.setGravity(Gravity.CENTER_VERTICAL); holder.text.setHeight(64); holder.icon.setMinimumHeight(64); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.text.setText(DATA[position]); holder.icon.setImageBitmap((bmp[position])); return convertView; } static class ViewHolder { TextView text; ImageView icon; } } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); efficientAdapter = new EfficientAdapter(this); setListAdapter(efficientAdapter); and want to add a text view on the top of list...but it should not be the list item -- A N K ! T.. -- 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+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to Android Development_ Version 3.1 Available! -- 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+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more