I am using share option from my application to social media. Android default share dialog works fine. I want to customize the dialog so that I can rearrange the share dialog UI similarly as in Flipboard android app. Can any one point out how to do that?
Asked
Active
Viewed 4,323 times
3
-
3see this example may be helpful for you http://clickclickclack.wordpress.com/2012/01/03/intercepting-androids-action_send-intents/ – ρяσѕρєя K Dec 10 '12 at 19:17
-
That is a good example. I will try that. – intrepidkarthi Dec 11 '12 at 05:39
-
example is working but you will need to make some changes in it – ρяσѕρєя K Dec 11 '12 at 05:44
-
like you will need to create an R.layout.basiclistview xml for listview row. – ρяσѕρєя K Dec 11 '12 at 05:48
-
@intrepidkarthi are u done custom share dialog – kartheeki j Sep 21 '15 at 11:22
1 Answers
1
i faced this problem. i found solution in this answer i hope it helps you too..
I write the code of this post below in case of not exist in the future:
You must use a custom ListAdapter to add your image. On way is to subclass the ArrayAdapter (used by default by the AlertDialog). Here is an example:
final Item[] items = {
new Item("Email", android.R.drawable.ic_menu_add),
new Item("Facebook", android.R.drawable.ic_menu_delete),
new Item("...", 0),//no icon for this one
};
ListAdapter adapter = new ArrayAdapter<Item>(
this,
android.R.layout.select_dialog_item,
android.R.id.text1,
items){
public View getView(int position, View convertView, ViewGroup parent) {
//Use super class to create the View
View v = super.getView(position, convertView, parent);
TextView tv = (TextView)v.findViewById(android.R.id.text1);
//Put the image on the TextView
tv.setCompoundDrawablesWithIntrinsicBounds(items[position].icon, 0, 0, 0);
//Add margin between image and text (support various screen densities)
int dp5 = (int) (5 * getResources().getDisplayMetrics().density + 0.5f);
tv.setCompoundDrawablePadding(dp5);
return v;
}
};
new AlertDialog.Builder(this)
.setTitle("Share Appliction")
.setAdapter(adapter, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
//...
}
}).show();
Here is the Item class
public static class Item{
public final String text;
public final int icon;
public Item(String text, Integer icon) {
this.text = text;
this.icon = icon;
}
@Override
public String toString() {
return text;
}
}

Community
- 1
- 1

Paraskevas Ntsounos
- 1,755
- 2
- 18
- 34