1. Are you ready for the Galaxy S20? Here is everything we know so far!

Images in Android

Discussion in 'Android Development' started by sehudson, Feb 2, 2011.

  1. sehudson

    sehudson Newbie
    Thread Starter

    I am trying to create a simple app just to practice development. In my main.xml layout I have:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:eek:rientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <RadioGroup android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:eek:rientation="vertical"
    android:id="@+id/QueGroup1">
    <RadioButton android:checked="false"
    android:id="@+id/option1" android:text="Excellent"/>
    <RadioButton android:checked="false"
    android:id="@+id/option2" android:text="Good"/>
    </RadioGroup>
    <ImageView android:id="@+id/fork" android:layout_width="25dp"
    android:layout_height="25dp"/>
    </LinearLayout>

    My main java file is pretty simple too:
    public class MyActivity extends Activity{
    private RadioButton rb1;
    private RadioButton rb2;
    private ImageView fork;

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    rb1=(RadioButton)findViewById(R.id.option1);
    rb2=(RadioButton)findViewById(R.id.option2);
    fork = (ImageView)findViewById(R.drawable.fork);
    }

    }

    The radio Buttons display fine, but its not showing the image. I put it in res/drawable folder (its a png), but I'm not seeing the image displayed. Any ideas?
     



    1. Download the Forums for Android™ app!


      Download

       
  2. miXer

    miXer Android Enthusiast

    You havent told the imageview to show any images.
    Add this to the imageview: android:src="@drawable/image-name"
     
Loading...
Similar Threads - Images Android
  1. Toneek
    Replies:
    2
    Views:
    2,193
  2. xarzu
    Replies:
    1
    Views:
    1,136
  3. LuckyBit33
    Replies:
    9
    Views:
    1,409
  4. h110m
    Replies:
    0
    Views:
    1,670
  5. OmTec Web
    Replies:
    2
    Views:
    1,633
  6. TomShawn1234
    Replies:
    5
    Views:
    706
  7. Roy Weil
    Replies:
    0
    Views:
    1,682
  8. 2heaVens
    Replies:
    0
    Views:
    3,446
  9. tapariasud
    Replies:
    0
    Views:
    1,743
  10. DolphinFlopFish
    Replies:
    9
    Views:
    10,024

Share This Page

Loading...