I want to display images inside single select when it appears inside dialog.
How can I do it?
I want to display images inside single select when it appears inside dialog.
How can I do it?
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.
I did not worked on it. But I have an Idea to you have combine the Three Examples on API Demos.
the steps you have to do are:
Sample Code:
new AlertDialog.Builder(MainActivity.this).setTitle("Share")setAdapter(new Listadapterclass(),new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface arg0,
int arg1) {
// TODO Auto-generated method stub
// the click event on the list item selected
}})
.create();
Hope It works.
Here you have working solution. Not mine, but I used described technique and it worked. Do not forget about img.setBounds(), it is necessary!
http://mgmblog.com/2010/06/10/arrayadapter-and-alertdialog-for-single-choice-items/
PS: original post does not display radiobutton, but my layout does. My single row XML layout file (animal_row.xml is missing in example) is here:
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/miastorow_text"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_vertical"
android:checkMark="?android:attr/listChoiceIndicatorSingle"
android:paddingLeft="6dip"
android:paddingRight="6dip"
android:textColor="#000"
/>