I'm trying to create a compound view using some wrapping some
ImageViews. Below I've abstracted files and the parts of my code that
I think are relevant. My problem is that the ImageViews don't show up
in the layout. Using hierarchyviewer I can see that the hierarchy of
views is correct but all of the nested LinearLayouts and ImageViews
have the same absolute_x and absolute_y coordinates which would seem
to be wrong. I don't understand why the inflater in MyCompundView
doesn't layout the LinearLayouts and ImageViews horizontally or
vertically as it should.
I've been scouring the android docs, group lists and asking about this
on IRC for a couple of days but no luck. Learned some great UI stuff,
but unfortunately nothing that's helped me solve this so far. Any
help here would be greatly appreciated.
TIA - iPayne
[Note: I'm happy to provide more detail below, but I was trying to
keep it as clear as possible.]
*** MyActivity.java ***
public class MyActivity extends Activity {
private MyCompoundView mcView = null;
private TextView tView1 = null;
private ListView lView = null;
private TextView tView2 = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.my-activity-layout);
mcView = (MyCompoundView)findViewById(id.my-compound-view-id);
tView1 = (TextView)findViewById(id.tview1-id);
lView = (ListView)findViewById(id.lview-id);
tView2 = (TextView)findViewById(id.tview2-id);
}
//...
}
*** MyCompoundView.java ***
public class MyCompoundView extends LinearLayout {
private Context c = null;
private AttributeSet a = null;
private ImageView iv1 = null;
private ImageView iv2 = null;
private ImageView iv3 = null;
private ImageView iv4 = null;
public MyCompoundView(Context c, AttributeSet a) {
super(c, a);
this.c = c;
this.a = a;
LayoutInflater li = (LayoutInflater)context.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
li.inflate(R.layout.my-compound-view-layout, this, true);
// dont see these...
iv1 = (ImageView) findViewById(R.id.iv1-id);
iv2 = (ImageView) findViewById(R.id.iv2-id);
iv3 = (ImageView) findViewById(R.id.iv3-id);
iv4 = (ImageView) findViewById(R.id.iv4-id);
// ... and this has no effect
iv1.setImageResource(R.drawable.new-image);
// ...
}
}
*** my-activity-layout.xml ***
<LinearLayout
...attrs>
<com.mypackage.MyCompoundView
...attrs />
<LinearLayout
...attrs>
<TextView
...attrs />
<ListView
...attrs />
<TextView
...attrs />
</LinearLayout>
</LinearLayout>
*** my-compound-view-layout.xml ***
<LinearLayout
...attrs>
<LinearLayout
...attrs>
<LinearLayout
...attrs>
<ImageView />
<ImageView />
</LinearLayout>
</LinearLayout>
<LinearLayout>
...attrs>
<LinearLayout
...attrs>
<ImageView />
<ImageView />
</LinearLayout>
</LinearLayout>
</LinearLayout>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en