Hi,
i want the content of the dialogue message to be change in different click .I have used onCreateDialog() function,but the problem is from the 2nd time the dialogue is shown with old data.
please help me .Its urgent.




/**
* This is the function to display custom dialog box with scroll-able text content.
* @param title - Title of the the dialog box displayed as the header
* @param body_text - Body of the dialog box displayed as the body of the dialog box with relevant details.
* @param context
*/
public static void createDialog(String title, String body_text, Context context) {
//Create the dialog.
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.diet_app);
dialog.setTitle(title);
dialog.setCancelable(true);
//Set up text
final TextView text = (TextView) dialog.findViewById(R.id.diet_app_body);
text.setText(body_text);
//Set up image
ImageView img = (ImageView) dialog.findViewById(R.id.diet_app_ImageView01);
img.setImageResource(R.drawable.logo);
//Set up button
Button button = (Button) dialog.findViewById(R.id.diet_app_yesbtn);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
text.setText("Changed");
//dialog.dismiss();
}
});
Button button_1 = (Button) dialog.findViewById(R.id.diet_app_cancelbtn);
button_1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="280px"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/diet_app_ImageView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true" />
<ScrollView
android:id="@+id/dialog_scroll"
android:layout_width="wrap_content"
android:layout_below="@+id/diet_app_ImageView01"
android:layout_height="200px">
<TextView
android:id="@+id/diet_app_body"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
</TextView>
</ScrollView>
<AbsoluteLayout
android:id="@+id/widget31"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/dialog_scroll"
>
<Button android:id="@+id/diet_app_yesbtn"
android:layout_width="100px"
android:layout_height="wrap_content"
android:text="Save"
android:layout_x="30px"
android:layout_y="0px"
android:textStyle="normal|bold"
android:textColor="#343434"
/>
<Button android:id="@+id/diet_app_cancelbtn"
android:layout_width="100px"
android:layout_height="wrap_content"
android:text="Cancel"
android:layout_x="160px"
android:layout_y="0px"
android:textStyle="normal|bold"
android:textColor="#343434"
/>
</AbsoluteLayout>
</RelativeLayout>
Users browsing this forum: No registered users and 5 guests