TextView is invisible in Custom Dialog when runing in simulator
I am facing to some weired problem where the "textview" of my custom
dialog get displayed in Eclipse Layout editor but not when it is running
in simulator/phone.
Following is my Custom dialog box layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="400dp"
android:background="#ffffff"
android:layout_height="350dp" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/rate_this_app_image_4" />
<TextView
android:id="@+id/rate_this_app_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imageView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="32dp"
android:text="@string/rate_this_app_text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/rate_this_app_yes_button"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_below="@+id/rate_this_app_text"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:text="@string/rate_this_app_yes" />
<Button
android:id="@+id/rate_this_app_not_now_button"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_below="@+id/rate_this_app_text"
android:layout_alignBaseline="@+id/rate_this_app_yes_button"
android:layout_marginLeft="120dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:text="@string/rate_this_app_notNow" />
<Button
android:id="@+id/rate_this_app_dont_ask_button"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_alignBaseline="@+id/rate_this_app_not_now_button"
android:layout_alignBottom="@+id/rate_this_app_not_now_button"
android:layout_toRightOf="@+id/rate_this_app_not_now_button"
android:text="@string/rate_this_app_dontAsk" />
</RelativeLayout>
Following is the Java code, which calls the dialog
private void showRatingDialog()
{
final Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.rate_this_app);
dialog.setTitle("Classifique este aplicativo");
//Register the Buttons
Button yesButton =
(Button)dialog.findViewById(R.id.rate_this_app_yes_button);
Button notNowButton =
(Button)dialog.findViewById(R.id.rate_this_app_not_now_button);
Button dontAskButton =
(Button)dialog.findViewById(R.id.rate_this_app_dont_ask_button);
TextView textView =
(TextView)dialog.findViewById(R.id.rate_this_app_text);
textView.setText("Gostaria de classificar este aplicativo agora?");
//Register the listener for 'Yes' button
yesButton.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
}});
//Register the listener for 'Not Now' button
notNowButton.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
}});
//Register the listener for 'Do not ask' button
dontAskButton.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
}});
dialog.show();
}
Now, following is how it get displayed in Eclipse Layout editor
Now, following is how it get displayed in Simulator/phone
As you can see, the TextView is disappeared! Please help!
No comments:
Post a Comment