I'm passing the URI of the resource I want to use to the activity that's supposed to display it with a description. Here's the code:
public void onClick(View v) {
final String root = "android.resource://" + getPackageName() + "/";
Intent myIntent = new Intent( v.getContext(), SingleMoveView.class);
myIntent.setData(Uri.parse(root + R.drawable.simby));
myIntent.putExtra("Desc", getResources().getString(R.string.simbus));
startActivity(myIntent);
}
and in the SingleMoveView class:
ImageView view = (ImageView) findViewById(R.id.singleMoveView);
TextView text = (TextView) findViewById(R.id.singleMoveDesc);
Uri path = getIntent().getData();
String desc = getIntent().getStringExtra("Desc");
view.setImageURI(path);
text.setText(desc);
What's happening is I've set up the ImageView and TextView in the XML as such:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:theme="@android:style/Theme.Holo.NoActionBar">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/singleMoveView"
android:layout_margin="20dp"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/singleMoveDesc"
android:layout_margin="20dp"
android:layout_below="@+id/singleMoveView"
android:layout_alignParentLeft="true"/>
</RelativeLayout>
But it's displaying the image in the absolute center of the screen:
Instead of on top w/text underneath. [Note the picture isn't displayed. view.setImageURI(path); was commented out]
Help please? How do I get it to display properly. Thanks! ^_^