Display Two Different LinearLayout's in ListView

Put your problem here if it does not fit any of the other categories.

Display Two Different LinearLayout's in ListView

Postby travisjames » Tue Apr 14, 2009 8:00 pm

I have this code and it is displayed in a listview over and over with different values, but I need to display both of my linear layouts beside each other in the listview, is this possible?
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. private View makeUserStatusView(Context context, TwitterEntry entry) {
  2.  
  3.        
  4.  
  5.                 ImageView iv = new ImageView(context);
  6.  
  7.         Bitmap photo = BitmapCache.getInstance().get(entry.getUser().getProfileImageURL());
  8.  
  9.  
  10.  
  11.         iv.setImageBitmap(photo);
  12.  
  13.         iv.setScaleType(ScaleType.CENTER);
  14.  
  15.         iv.setPadding(0, 4, 4, 0);
  16.  
  17.         iv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  18.  
  19.        
  20.  
  21.         TextView name = new TextView(context);
  22.  
  23.                 name.setTextSize(10);
  24.  
  25.                 name.setText(entry.getUser().getName());
  26.  
  27.                 name.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  28.  
  29.        
  30.  
  31.         TextView tv = new TextView(context);
  32.  
  33.         tv.setTextSize(12);
  34.  
  35.         tv.setText(entry.getText());
  36.  
  37.         tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  38.  
  39.        
  40.  
  41.         LinearLayout layout1 = new LinearLayout(context);
  42.  
  43.         layout1.setOrientation(LinearLayout.VERTICAL);
  44.  
  45.         layout1.setPadding(4, 2, 4, 2);
  46.  
  47.         layout1.addView(name);
  48.  
  49.         layout1.addView(iv);
  50.  
  51.        
  52.  
  53.         LinearLayout layout = new LinearLayout(context);
  54.  
  55.         layout.setOrientation(LinearLayout.HORIZONTAL);
  56.  
  57.         layout.setPadding(4, 2, 4, 2);
  58.  
  59.         layout.addView(tv);
  60.  
  61.        
  62.  
  63.         return layout;
  64.  
  65.     }
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


SO pretty much, I need to return both of the LinearLayouts, but I do not know how. Any Help?
travisjames
Junior Developer
Junior Developer
 
Posts: 17
Joined: Thu Apr 02, 2009 10:00 pm
Location: Cordova, Tennessee

Top

Re: Display Two Different LinearLayout's in ListView

Postby wilken » Wed Apr 15, 2009 7:22 am

Hi,
if i understand correctly, you want every item in your list to display the two layouts side by side?
if this is so, then create another linearlayout that contains the listviews side by side (using the LinearLayout.HORIZONTAL option.)
wilken
Developer
Developer
 
Posts: 35
Joined: Wed Oct 08, 2008 8:22 am

Postby travisjames » Wed Apr 15, 2009 1:58 pm

Thank you for your reply. It worked, I should have thought of that. :]
travisjames
Junior Developer
Junior Developer
 
Posts: 17
Joined: Thu Apr 02, 2009 10:00 pm
Location: Cordova, Tennessee

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 20 guests