Variable width Views in WeatherAdapter with Screen Shot

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

Variable width Views in WeatherAdapter with Screen Shot

Postby milkround » Thu Jul 02, 2009 12:10 pm

Hi,

I am using the same code as in WeatherAdapter to display a scrolling list.

Each line has two Textviews and there are two types of line

Type A Lines :-

These have two width=Wrap_Content TextViews.

Type B Lines :-

These have a TextView with a width of 100px and one with width=Wrap_Content.

Image

This works fine until I come to reuse the convertView when the following code does NOT set the width back to Wrap_Content:-

value.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT));

I even tried a
value.forceLayout();
to noavail!

Any ideas????

Many thanks Steve

fuller version

if(null==convertView){

}
else{
TextView value=(TextView)convertView.findViewById(R.id.value);
TextView label=(TextView)convertView.findViewById(R.id.label);
value.setPadding(2, 2, 0, 0);
value.setGravity(Gravity.CENTER);
value.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
value.setTextSize(26);
value.setText(item1);
label.setText(item2);
label.setTextSize(12);
label.setGravity(Gravity.TOP);
convertView.setTag(new Integer(tag[position]));
return convertView;
}
milkround
Developer
Developer
 
Posts: 34
Joined: Sat May 02, 2009 2:29 pm
Location: UK & Malta

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Exabot [Bot] and 12 guests