[SOLVED] Dyn. ListView (with img+text) between stat. Buttons

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

[SOLVED] Dyn. ListView (with img+text) between stat. Buttons

Postby emrah » Wed Dec 31, 2008 2:54 am

Hi,

I currently try to design an UI which should look like this:

Code: Select all
------------------------------------------
|       4  Static Buttons                   | <-- This should be visible every time
------------------------------------------
|  image1   text1 of Item1 in list   /|
|               text2 of  Item1 in list   ||
|-------------------------------------  ||
|  image2   text1 of Item2 in list    || <--  The ListView should be filled dynamically
|               text2 of  Item2 in list   ||      and should be scrollable
|------------------------------------- ||
|  image3   text1 of  Item3 in list  ||
|               text2 of  Item3 in list  ||
|--------------------------------------||
|                                                ||
|                                                ||
|                                                ||
|                                                ||
|                                                ||
|                                                ||
|                                                |
------------------------------------------
|       2  Static Buttons                   | <-- This should be visible every time too
------------------------------------------


What I want is a ListView which has four buttons at the top and two at the bottom. The buttons on the top switch to other views/activities and the buttons on the bottom switch to the next type of information.

The problem is that my ListView has the 4+2 buttons in every ListEntry (see the attached picture: files/1_826.png). For my app I used the EfficientAdapter-Example of the API and I have done the tutorials of plusminus (iconifiedText). I know where the reason is, but I don't know how to fix it.

Can anybody explain this to me how I manage it or has anybody a solution?

Greets,
emrah


JAVA-Code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class ListInformationActivity extends ListActivity {
  2.  
  3. private static final String[] mTi = {"Location 1", "Location 2", "Location 3", "Location 4", "Location 5", "Location 6", "Location 7", "Location 8", "Location 9", "Location 10" };
  4.         private static final String[] mLocations = {"Location 1", "Location 2", "Location 3", "Location 4", "Location 5", "Location 6", "Location 7", "Location 8", "Location 9", "Location 10" };
  5.  
  6. @Override
  7.     public void onCreate(Bundle savedInstanceState) {
  8.         super.onCreate(savedInstanceState);
  9.         setListAdapter(new ListInformationAdapter(this));
  10.         }
  11.  
  12.     private static class ListInformationAdapter extends BaseAdapter {
  13.  
  14.                 private LayoutInflater mInflater;
  15.                
  16.                 public ListInformationAdapter(Context context) {
  17.                     mInflater = LayoutInflater.from(context);
  18.                 }
  19.                
  20.                 @Override
  21.                 public int getCount() {
  22.                         return mTitles.length;
  23.                 }
  24.  
  25.                 @Override
  26.                 public Object getItem(int position) {
  27.                         return position;
  28.                 }
  29.  
  30.                 @Override
  31.                 public long getItemId(int position) {
  32.                         return position;
  33.                 }
  34.  
  35.                 @Override
  36.                 public View getView(int position, View convertView, ViewGroup parent) {
  37.  
  38.                     ViewHolder holder;
  39.  
  40.                     if (convertView == null) {
  41.                         convertView = mInflater.inflate(R.layout.list_information, null);
  42.  
  43.                         holder = new ViewHolder();
  44.                         holder.title = (TextView) convertView.findViewById(R.id.title);
  45.                         holder.location = (TextView) convertView.findViewById(R.id.location);
  46.  
  47.                         convertView.setTag(holder);
  48.                     } else {
  49.                         holder = (ViewHolder) convertView.getTag();
  50.                 }
  51.  
  52.                 holder.title.setText(mTi[position]);
  53.                 holder.location.setText(mLocations[position]);
  54.  
  55.                 return convertView;
  56.                }
  57.                
  58.         static class ViewHolder {
  59.             TextView title;
  60.             TextView location;
  61.         }
  62.     }/**/
  63. }
  64.  
Parsed in 0.040 seconds, using GeSHi 1.0.8.4



XML-Layout:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.         android:id="@+id/view_a"
  4.         android:orientation="vertical"
  5.         android:layout_width="wrap_content"
  6.         android:layout_height="wrap_content">
  7.        
  8.         <LinearLayout
  9.         android:orientation="horizontal"
  10.         android:layout_height="wrap_content"
  11.         android:layout_width="fill_parent"
  12.         android:layout_gravity="center">
  13.  
  14.                 <Button
  15.                 android:id="@+id/button_a"
  16.                 android:layout_width="0dip"
  17.                 android:layout_height="wrap_content"
  18.                 android:layout_weight="1"
  19.                 android:text="@string/a_title">
  20.                 </Button>
  21.                
  22.                 <Button
  23.                 android:id="@+id/button_l"
  24.                 android:layout_width="0dip"
  25.                 android:layout_height="wrap_content"
  26.                 android:layout_weight="1"
  27.                 android:text="@string/l_title">
  28.                 </Button>
  29.                
  30.                 <Button
  31.                 android:id="@+id/button_s"
  32.                 android:layout_width="0dip"
  33.                 android:layout_height="wrap_content"
  34.                 android:layout_weight="1"
  35.                 android:text="@string/s_title">
  36.                 </Button>
  37.                
  38.                 <Button
  39.                 android:id="@+id/button_n"
  40.                 android:layout_width="0dip"
  41.                 android:layout_height="wrap_content"
  42.                 android:layout_weight="1"
  43.                 android:text="@string/n_title">
  44.                 </Button>
  45.                
  46.         </LinearLayout>
  47.        
  48.         <ListView android:id="@+id/android:list"
  49.          android:layout_width="fill_parent"
  50.        android:layout_height="wrap_content"
  51.        android:layout_weight="1"
  52.        android:drawSelectorOnTop="false" />
  53.        
  54.         <TextView android:id="@+id/title"
  55.                 android:layout_width="wrap_content"
  56.                 android:layout_height="wrap_content"/>
  57.         <TextView android:id="@+id/location"
  58.                 android:layout_width="wrap_content"
  59.                 android:layout_height="wrap_content"/>
  60.        
  61.         <LinearLayout
  62.         android:orientation="horizontal"
  63.         android:layout_height="wrap_content"
  64.         android:layout_width="fill_parent"
  65.         android:layout_gravity="center">
  66.        
  67.                 <Button
  68.                 android:id="@+id/button_previous"
  69.                 android:layout_width="0dip"
  70.                 android:layout_height="wrap_content"
  71.                 android:layout_weight="1"
  72.                 android:text="@string/previous">
  73.                 </Button>
  74.        
  75.                 <Button
  76.                 android:id="@+id/button_next"
  77.                 android:layout_width="0dip"
  78.                 android:layout_height="wrap_content"
  79.                 android:layout_weight="1"
  80.                 android:text="@string/next">
  81.                 </Button>
  82.        
  83.         </LinearLayout>
  84.        
  85. </LinearLayout>
  86.  
Parsed in 0.009 seconds, using GeSHi 1.0.8.4
Attachments
1.png
currently UI
1.png (14.66 KiB) Viewed 300 times
Last edited by emrah on Fri Jan 02, 2009 1:08 am, edited 1 time in total.
emrah
Freshman
Freshman
 
Posts: 5
Joined: Mon May 12, 2008 7:31 pm
Location: Europe/Austria/Vienna

Top

Postby Emmanuel7 » Thu Jan 01, 2009 3:49 am

Use two different Xml layout files :
the first one for the screen layout : 4 top buttons + Listview + 2 bottom buttons

And the second one for a listView entry ONLY : so with your two textviews.
Use the first one in the onCreate of your activity (with a setContentView ), and the second one in your adapter.

Hope it helps
Emmanuel7
Senior Developer
Senior Developer
 
Posts: 164
Joined: Fri Dec 12, 2008 2:17 am
Location: Paris

Postby emrah » Thu Jan 01, 2009 3:30 pm

Thanks for your reply, I will try it out, and will report after.

Greets,
emrah
emrah
Freshman
Freshman
 
Posts: 5
Joined: Mon May 12, 2008 7:31 pm
Location: Europe/Austria/Vienna

Postby emrah » Fri Jan 02, 2009 1:06 am

My report:
Works fine, now it looks like it should. :-) Your hints were very helpful...
Merci beaucoup Emmanuel7!

Greets,
emrah
emrah
Freshman
Freshman
 
Posts: 5
Joined: Mon May 12, 2008 7:31 pm
Location: Europe/Austria/Vienna

How to design the Adapter XML file

Postby rajendrakumar » Wed Jan 07, 2009 2:38 pm

Can any one tell me how to desing the second Adapter XML file with two text views
rajendrakumar
Developer
Developer
 
Posts: 40
Joined: Thu Jan 01, 2009 7:57 am

Postby Emmanuel7 » Wed Jan 07, 2009 6:27 pm

Not tested cos I'm at work, but it should be something like that ?

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <LinearLayout
  5.  
  6.     android:orientation="horizontal"
  7.  
  8.     android:layout_height="wrap_content"
  9.  
  10.     android:layout_width="fill_parent"
  11.  
  12. >
  13.  
  14. <TextView android:id="@+id/title"
  15.  
  16.          android:layout_width="wrap_content"
  17.  
  18.          android:layout_height="wrap_content"/>
  19.  
  20. <TextView android:id="@+id/location"
  21.  
  22.          android:layout_width="wrap_content"
  23.  
  24.          android:layout_height="wrap_content"/>
  25.  
  26. </LinearLayout >
  27.  
  28.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4
Emmanuel7
Senior Developer
Senior Developer
 
Posts: 164
Joined: Fri Dec 12, 2008 2:17 am
Location: Paris

Top

Working....

Postby rajendrakumar » Thu Jan 08, 2009 4:34 am

HI,

That is working fine.....


I got it...

can you tell me "How to create a Manual Curser" with dydnamic data.
rajendrakumar
Developer
Developer
 
Posts: 40
Joined: Thu Jan 01, 2009 7:57 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 3 guests