Created
September 22, 2018 00:40
-
-
Save CreatorB/f15e9174fff8473f16d3d6e5a46e50a7 to your computer and use it in GitHub Desktop.
custom dialog android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
showMyDialog(this); | |
} | |
public void showMyDialog(final Activity activity) { | |
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity); | |
LayoutInflater inflater = activity.getLayoutInflater(); | |
final View dialogView = inflater.inflate(R.layout.my_custom_dialog, null); | |
dialogBuilder.setView(dialogView); | |
final TextView tvJudul = (TextView) dialogView.findViewById(R.id.tvTitle); | |
tvJudul.setText("My Title"); | |
dialogBuilder.setTitle(activity.getString(R.string.setting_lang)); | |
dialogBuilder.setPositiveButton(activity.getString(R.string.act_ok), new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog, int whichButton) { | |
int position = spinner1.getSelectedItemPosition(); | |
changeLang(activity, position); | |
} | |
}); | |
// dialogBuilder.setNegativeButton(activity.getString(R.string.setting_cancel), new DialogInterface.OnClickListener() { | |
// public void onClick(DialogInterface dialog, int whichButton) { | |
// dialog.dismiss(); | |
// } | |
// }); | |
AlertDialog b = dialogBuilder.create(); | |
b.show(); | |
b.setCancelable(false); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment