*<Button
android:textAllCaps="false"
android:id="@+id/topic_spinner"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="left|center_vertical"
android:background="@android:drawable/btn_dropdown"
android:singleLine="true"
android:text="Choose a topic"
android:textSize="20dp"
>
</Button> Button topic_spinner; topic_spinner.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final String[] items = new String[]{"Topic1", "Topic2", "Topic3"};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_dropdown_item, items);
new AlertDialog.Builder(getActivity()).setTitle("The Topic").setAdapter(adapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
topic_spinner.setText(items[which]);
dialog.dismiss();
}
}).create().show();
}
});*
solved How to show a dropdown type of menu on tap of button? [closed]