Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
530 views
in Technique[技术] by (71.8m points)

android image inside single select

I want to display images inside single select when it appears inside dialog.

alt text http://www.freeimagehosting.net/uploads/bfb1c90d61.png

How can I do it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can override everything and create it from scratch. First create an xml describing the content you want. For example:

<!-- test.xml -->
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
 android:background="@color/white">
 <ImageView android:id="@+id/ImageView01"
  android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
  android:src="@drawable/facebook"></ImageView>
 <TextView android:id="@+id/TextView01" 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" 
            android:layout_toRightOf="@+id/ImageView01"
  android:text="Facebook" 
            android:textSize="40sp"></TextView>
 <RadioButton android:id="@+id/RadioButton01"
  android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
  android:layout_toRightOf="@+id/TextView01"></RadioButton>
</RelativeLayout>

Then build this xml using the alert dialog. You can let the activity handle your dialog and just override the onCreateDialog like this:

@Override
protected Dialog onCreateDialog(int id) {
    View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.test, null);
    return new AlertDialog.Builder(MainActivity.this).setView(view).setTitle("Share")
                    .create();
}

You can then override onClick to store the state in your StaticPreferences files. This way you'll have complete control over all the elements in your view.

One final piece of advice, when creating the xml make sure that you create as flat a layout as possible so that the code is optimized. You can also play with the list layout to create something like this.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...