Dialog With RadioButton Android Example
private void dialogModeFC() {
try {
final AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this)
.setTitle(R.string.select_dialog)
//.setItems(
.setSingleChoiceItems(R.array.select_dialog_items, -1
, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
/* User clicked so do some stuff
<item>Happy New Year</item>
<item>Merry Christmas</item>
<item>I Love You</item>
*/
String[] items = getResources().getStringArray(R.array.select_dialog_items);
// list with boolean variables - which is true
// for (int i = 0; i < _listMode.size(); i++) {
// _listMode.set(i, false);
// }
// _listMode.set(which, true);
dialog.dismiss();
// new AlertDialog.Builder(MainActivity.this)
// .setMessage("You selected: " + which + " , " + items[which])
// .show();
}
})
.create();
alertDialog.show();
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(), e.getMessage().toString(), Toast.LENGTH_LONG)
.show();//("dialogModeFC", e.getMessage().toString());
}
}// end dialogModeFC
396LW NO topic_id
AD
Další témata ....(Topics)
// solution 1
ImageView imageView = (ImageView)findViewById(R.id.myimage);
imageView.setImageDrawable(null);
// or
imageView.setImageResource(0);
// solution 2 hide ImageView
imageView.setVisibility(View.INVISIBLE);
// solution 3 resize ImageView 0, 0
hImageViewSemafor.setLayoutParams(new LinearLayout.LayoutParams(0,0));
Adding TableRow with a View TextView (EditText Button) programmically dynamically to TableLayout Android sample basic example.
MainClass.java
main.xml
MainClass.java
public class MainClass extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TableLayout tl = (TableLayout)findViewById(R.id.tableLayout1);
TableRow row = new TableRow(this);
TextView tv = new TextView(this);
tv.setText("This is text");
tl.addView(row);
row.addView(tv);
}
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="//schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TableLayout android:layout_width="fill_parent"
android:id="@+id/tableLayout1" android:layout_height="wrap_content">
</TableLayout>
</LinearLayout>
Admob testing on emulator issue.
Android Eclipse code warning:
setTesting(boolean) from the type AdRequest is deprecated
Solution:
adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
Android Eclipse code warning:
setTesting(boolean) from the type AdRequest is deprecated
Solution:
adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
AdView adView = new AdView(this, AdSize.BANNER, "a14d9..........");//MY_AD_UNIT_ID
AdRequest adRequest = new AdRequest();
adRequest.setTesting(true); // deprecated
adRequest.addTestDevice(AdRequest.TEST_EMULATOR); // OK
adView.loadAd(adRequest);
// warnning
private List list = new ArrayList();
// ok /put type of added object
private List<String> list = new ArrayList<String>();
onSaveInstanceState, onRestoreInstanceState , save preferences
int mCurrentPhotoIndex = 0;
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putInt("photo_index", mCurrentPhotoIndex);
super.onSaveInstanceState(outState);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
mCurrentPhotoIndex = savedInstanceState.getInt("photo_index");
super.onRestoreInstanceState(savedInstanceState);
}
// or save preferences for new start of Activity in onStop
//onCreate or onResume or onStart etc.
public void loadPreferences() {
SharedPreferences settings = getSharedPreferences(F.PREFERENCES_NAME, 0);
mCurrentPhotoIndex = settings.getInt("mCurrentPhotoIndex",mCurrentPhotoIndex);
// String_sOtazka = settings.getString("_sOtazka", _sOtazka);
}
// onStop
public void savePreferences() {
SharedPreferences settings = getSharedPreferences(PREFERENCES_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putInt("mCurrentPhotoIndex", mCurrentPhotoIndex);
// String, boolean, float ...
// editor.putString("mButton1", mButton1.getText().toString());
editor.commit();
}
Editace: 2012-12-30 11:42:52
Počet článků v kategorii: 396
Url:dialog-with-radiobutton-android-example