I have a dialog, which is created with this code:
final Dialog dialog1 = new Dialog(Test.this);
dialog1.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog1.setContentView(R.layout.test_layout);
dialog1.setCancelable(true);
...
The layout file 'test_layout.xml' contains a typical TextView:
<TextView
android:id="#+id/tv_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Test" />
I want in the code to set this TextView invisible (gone) in some cases.
I tried following:
TextView tv = (TextView) dialog1.findViewById(R.id.tv_username);
tv.setVisibility(TextView.GONE);
But the TextView still appears in the dialog. If I set in the layout xml file android:visibility="gone" it is not appearing in the dialog. But I need to do it via code.
Here the whole code:
if (whichButton == 1) {
final Dialog dialog1 = new Dialog(Test.this);
dialog1.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog1.setContentView(R.layout.test_layout);
dialog1.setCancelable(true);
TextView tv = (TextView) dialog1.findViewById(R.id.tv_username);
tv.setVisibility(View.GONE);
...
dialog1.show();
}
Here the whole XML file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="250dp"
android:layout_height="match_parent"
>
<TextView
android:id="#+id/tv_name"
android:paddingTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="15dp"
android:textSize="14dp"
android:text="Name:" />
<EditText
android:id="#+id/username"
android:hint="#string/enterName"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:maxLength="15"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:scrollHorizontally="true"
android:capitalize="words"
android:singleLine="true"
android:gravity="fill_horizontal"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/tv_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Test" />
<TextView
android:id="#+id/tv_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="15dp"
android:textSize="14dp"
android:text="#string/message" />
<EditText
android:id="#+id/tip"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:maxLength="290"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:scrollbars="vertical"
android:inputType="textMultiLine"
android:capitalize="words"
android:gravity="fill_horizontal"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="#+id/button"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/send_message" />
</LinearLayout>
Try tv.setVisibility(View.INVISIBLE);
I found a solution or workaround.
The dialog was created in the the onClick method of an AlertDialog.
Now I use the showDialog() method and handle it in the corresponding callback method.
There it is working fine.
I do not understand why this is working, but I only want to tell other users how they can solve this issue.
I would be happy if someone can come up with a clarification.
Related
In the current version of instagram app (Todays date 24-06-2021) ,inside the profile activity/fragment when hamburgur button is pressed (or simply the 3 line icon) now a menu pops up from bottom and can be scroll down by swipe down ,previously when cliked it opens a new fragment/activity
im in love with this animation or a view and im despirat to implement it in my app
but the problem is i dont know what it is called
i want to know what it is exactly and also similar kind of animation or a view is also there in pintrest app
Screen Shot
Update 1
how can i navigate to a fragment from a bottom sheet for eg if in my bootomsheet there is 3 textview i want that if any textView is cliked it should open the respected new fragment i.e if a editprofle textView is clicked it open the editprofile fragment this is how my bottomsheet opens up
Profile_Fragment.java
accountSettings the imageView when clicked the bottomSheetopens up
accountSettings.setOnClickListener(
v -> {
BottomSheet bottomSheet = new BottomSheet();
bottomSheet.show(requireActivity().getSupportFragmentManager(), bottomSheet.get Tag());
}
);
bottom_sheet_profile.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="#+id/slidedownview"
android:layout_width="40dp"
android:layout_height="3dp"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:background="#drawable/rounded_corner_bottomsheetline"
android:layout_marginTop="11dp"/>
<TextView
android:id="#+id/settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/slidedownview"
android:layout_alignParentStart="true"
android:layout_marginStart="30dp"
android:layout_marginTop="20dp"
android:elevation="10dp"
android:text="#string/settings"
android:textColor="#color/white"
android:textSize="20sp"
android:textStyle="normal" />
<TextView
android:id="#+id/edit_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/settings"
android:layout_alignParentStart="true"
android:layout_marginStart="30dp"
android:layout_marginTop="17dp"
android:elevation="10dp"
android:text="#string/edit_profile"
android:textColor="#color/white"
android:textSize="20sp"
android:textStyle="normal" />
<TextView
android:id="#+id/favorite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/edit_profile"
android:layout_alignParentStart="true"
android:layout_marginStart="30dp"
android:layout_marginTop="17dp"
android:elevation="10dp"
android:text="#string/favorite"
android:textColor="#color/white"
android:textSize="20sp"
android:textStyle="normal" />
<TextView
android:id="#+id/log_out"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/favorite"
android:layout_alignParentStart="true"
android:layout_marginStart="30dp"
android:layout_marginTop="17dp"
android:layout_marginBottom="15dp"
android:elevation="10dp"
android:text="#string/log_out"
android:textColor="#color/white"
android:textSize="20sp"
android:textStyle="normal" />
</RelativeLayout>
Include the following library in your app.gradle file.
implementation 'com.google.android.material:material:<version>'
create custom layout bottom_sheet_dialog_layout.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Settings"
android:drawableStart="#drawable/ic_settings"
android:layout_gravity="center_vertical"
android:padding="8dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Archive"
android:drawableStart="#drawable/ic_archive"
android:layout_gravity="center_vertical"
android:padding="8dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your Activity"
android:drawableStart="#drawable/ic_activity"
android:layout_gravity="center_vertical"
android:padding="8dp"/>
....
....
....
in Class file
final BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this);
bottomSheetDialog.setContentView(R.layout.activity_sof);
TextView settings = bottomSheetDialog.findViewById(R.id.settings);
TextView archive = bottomSheetDialog.findViewById(R.id.archive);
TextView your_activity = bottomSheetDialog.findViewById(R.id.activity);
...
...
...
bottomSheetDialog.show();
If you want to click event
settings.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "Copy is Clicked ", Toast.LENGTH_LONG).show();
bottomSheetDialog.dismiss();
}
});
I have tried many ways and i could not get this alignment issue resolved . And i am not sure that where i am going wrong .
My XML :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:background="#color/popover">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textColor="#000000"
android:layout_marginTop="15dp"
android:layout_marginBottom="2dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textColor="#000000"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textColor="#000000"
android:layout_marginTop="2dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textColor="#000000"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:layout_margin="5dp"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Small Text"
android:textColor="#000000"
android:layout_margin="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Small Text"
android:textColor="#000000"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="15dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" >
<ImageButton
android:id="#+id/locationalert_dont"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#drawable/dontallow_btnaction" />
<ImageButton
android:id="#+id/locationalert_ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:background="#drawable/ok_btnaction" />
</LinearLayout>
</LinearLayout>
And the class file :
public void showLocationDialog()
{
Dialog dialog = new Dialog(Homescreen.this);
dialog.setContentView(R.layout.locationalert);
TextView tv1 = (TextView)dialog.findViewById(R.id.textView1);
TextView tv2 = (TextView)dialog.findViewById(R.id.textView2);
TextView tv3 = (TextView)dialog.findViewById(R.id.textView3);
TextView tv4 = (TextView)dialog.findViewById(R.id.textView4);
TextView tv5 = (TextView)dialog.findViewById(R.id.textView5);
TextView tv6 = (TextView)dialog.findViewById(R.id.textView6);
ImageButton ok = (ImageButton)dialog.findViewById(R.id.locationalert_ok);
ImageButton dont = (ImageButton)dialog.findViewById(R.id.locationalert_dont);
dialog.show();
}
Actually i have a button in a class and click on it pop-ups this dialog . But the dialog appears as
In the Screenshot , i am getting a header black bar along with the pop-up dialog and i am not sure how to remove it .
Any related answers are advisable . Thanks in advance .
try below code :-
final Dialog dialog = new Dialog(ActivityName.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // hide title bar
dialog.setContentView(R.layout.vip_services_other_dialog);
// hide black background
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
refer link
Use
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
Please also go through:
Android Window and Related Flags and Dialogs
In your XML(locationalert), set Linear Layout Background as:
android:background="#android:color/transparent"
and in your showLocationDialog() method, add
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(R.color.YOURCOLOR));
this is the solution of your problem
Dialog dialog = new Dialog(Homescreen.this,android.R.style.Theme_Translucent_NoTitleBar );
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.locationalert);
You can hide the title bar and the background of a dialog like this:
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
Hope this helps..:)
I have been trying to work out my first android app with samples and code from the internet.
Following them I got the following error
**"Brew_Time_Add cannot be resolved or is not a field."**
for the line in the code
**Button brewAddTime = (Button) findViewById(R.id.brew_time_up);**
The xml for this part -
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:padding="10dip">
<Button
android:id="#+id/brew_time_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="40dip" />
<TextView
android:id="#+id/brew_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0:00"
android:textSize="40dip"
android:padding="10dip" />
<Button
android:id="#+id/brew_time_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+"
android:textSize="40dip" />
</LinearLayout>
The Java Code for the same -
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button brewAddTime = (Button) findViewById(R.id.brew_time_up);
Button brewDecreaseTime = (Button) findViewById(R.id.brew_time_down);
Button startBrew = (Button) findViewById(R.id.brew_start);
TextView brewCountLabel = (TextView) findViewById(R.id.brew_count_label);
TextView brewTimeLabel = (TextView) findViewById(R.id.brew_time);
}
Why is the error and how can it be solved?
Please see image at- http://db.tt/kbjq6u5o
Thanks in advance.
Do you have such an image in your layout? If you have then save your project and clean it.
Got to project -> clean to clean it.
You are missing the xmls declaration in your layout - add xmlns:android="http://schemas.android.com/apk/res/android" to your layout, like so:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:padding="10dip">
<Button
android:id="#+id/brew_time_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="40dip" />
<TextView
android:id="#+id/brew_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0:00"
android:textSize="40dip"
android:padding="10dip" />
<Button
android:id="#+id/brew_time_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+"
android:textSize="40dip" />
Though you will still have errors for both brew_start and brew_count_label as they are not in the xml.
Add these in the layout file. Your layout file is missing these 2 elements
<TextView
android:id="#+id/brew_count_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0:00"
android:textSize="40dip"
android:padding="10dip" />
<Button
android:id="#+id/brew_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Start"
android:textSize="40dip" />
I'm actually coding an app for Android and I need some help to do something.
I need to do a kind of popup message with this image: http://img716.imageshack.us/img716/9331/postitz.png. This image must have 2 TextView, one of them is a title and the other one is the message.
I have tried some options like Dialog with its own layout, own style, but the image fills all the screen instead of wrap the content of the TextViews. I have also tried to do it with a new Activity and occurs the same, the Image fills all the screen.
My actual layout is this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_vertical"
android:background="#android:color/white">
<LinearLayout
android:id="#+id/img_postit"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="#drawable/postit"
android:orientation="vertical">
<TextView
android:id="#+id/note_titulo"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:padding="30dp"/>
<TextView
android:id="#+id/note_descr"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:padding="30dp"/>
</LinearLayout>
</LinearLayout>
But I have tried with a lot of different combinations, RelativeLayout, FrameLayout, and I cannot find the solution to do this.
Any idea of how to resolve it?.
Thank's for all.
you said you used as a new activity. Did you use android:theme="#android:style/Theme.Dialog in your manifest file?
And be sure that the image is little bit smaller one such that it will be suitable to act as a pop up..
If you used a dialog what exactly is the problem? Didnt you get the dialog as a pop up ?
(i think the image is larger so that it might fill the entire screen)
Create your own class extending dialog.And use layout like following. I use this in one of my apps and the dialog window is wrapped around the buttons :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/background"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/ll2"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:layout_below="#+id/ll1"
android:gravity="left"
android:orientation="horizontal"
android:paddingBottom="5dp" >
<RadioButton
android:id="#+id/start"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="#+id/stop"
android:background="#drawable/start_on"
android:button="#android:color/transparent"
android:checked="true" />
<RadioButton
android:id="#+id/stop"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:background="#drawable/stop_off"
android:button="#android:color/transparent" />
<RadioButton
android:id="#+id/restart"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/stop"
android:background="#drawable/restart_on"
android:button="#android:color/transparent" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/lltext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/detail_credit"
android:layout_below="#+id/ll2"
android:layout_marginBottom="15dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/startText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/stopText"
android:text="#string/start_server_icon"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/white"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:id="#+id/stopText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:text="#string/stop_server_icon"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/white"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:id="#+id/restartText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/stopText"
android:text="#string/restart_server_icon"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/white"
android:textSize="12sp"
android:textStyle="bold" />
</RelativeLayout>
<Button
android:id="#+id/dialogButtonOK"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_below="#+id/lltext"
android:layout_centerHorizontal="true"
android:text="OK" />
</RelativeLayout>
final Dialog dialog_my = new Dialog(FIRST.this,
android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
dialog_my.setContentView(R.layout.about_us); //<PUT YOUR LAYOUT ID HERE>
TextView date = (TextView) dialog_my.findViewById(R.id.date);
TextView thought = (TextView) dialog_my.findViewById(R.id.thought);
TextView ok = (TextView) dialog_my.findViewById(R.id.ok);
TextView link = (TextView) dialog_my.findViewById(R.id.link);
TextView contact = (TextView) dialog_my.findViewById(R.id.contact);
WindowManager.LayoutParams lp = dialog_my.getWindow().getAttributes();
lp.dimAmount = 0.0f;
dialog_my.getWindow().setAttributes(lp);
dialog_my.getWindow().addFlags(
WindowManager.LayoutParams.FLAG_DIM_BEHIND);
dialog_my.show();
I made a TextView and a button. Clicking on the button will save the value entered by the user in a variable. The problem is, when the keyboard pops up after touching the textview, only the first character will be visible properly. The rest of the characters aren't displayed. An _ appears instead of the other characters. After i'm done typing and press the back button and when the keyboard disappears, I can see the characters properly. What is the problem?
Button okbutton = (Button) findViewById(R.id.okbutton);
okbutton.setClickable(true);
final TextView radius = (TextView) findViewById(R.id.radius);
okbutton.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
i=radius.getText().toString();
}
});
Here is the complete layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<ImageView android:id="#+id/icon" android:src="#drawable/settings"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="10px"></ImageView>
<TextView android:textSize="20px" android:typeface="sans"
android:layout_height="wrap_content" android:id="#+id/alarmset"
android:layout_width="fill_parent" android:text="#string/alarmset"
android:textStyle="bold" android:gravity="center"
android:drawablePadding="10px" android:paddingTop="10px"></TextView>
<TextView android:text="#string/distance" android:id="#+id/distance"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_below="#+id/alarmset"></TextView>
<TextView android:id="#+id/kmvalue" android:layout_below="#+id/distance"
android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<TextView android:text="#string/km" android:id="#+id/km"
android:layout_below="#+id/distance" android:layout_toRightOf="#+id/kmvalue"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="10px"></TextView>
<TextView android:text="#string/musichooser" android:id="#+id/musictext"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_below="#+id/km" android:paddingTop="10px"></TextView>
<Button android:id="#+id/chooser" android:layout_below="#+id/musictext"
android:drawableRight="#drawable/lov_ena"
android:layout_alignParentRight="true" android:layout_width="wrap_content"
android:layout_height="30px" android:layout_alignBaseline="#+id/musicfile">
</Button>
<EditText android:id="#+id/musicfile" android:layout_width="fill_parent"
android:layout_below="#+id/musictext" android:layout_toLeftOf="#id/chooser"
android:layout_height="40px">
</EditText>
<TextView android:text="#string/imgchooser" android:id="#+id/imgText"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_below="#+id/chooser" android:paddingTop="20px"></TextView>
<Button android:id="#+id/imgPicker" android:layout_below="#+id/imgText"
android:drawableRight="#drawable/lov_ena"
android:layout_alignParentRight="true" android:layout_width="wrap_content"
android:layout_height="30px" android:layout_alignBaseline="#+id/imgfile">
</Button>
<EditText android:id="#+id/imgfile" android:layout_width="fill_parent"
android:layout_below="#+id/imgText" android:layout_toLeftOf="#id/chooser"
android:layout_height="40px">
</EditText>
<RelativeLayout android:id="#+id/InnerRelativeLayout"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentBottom="true" android:layout_centerInParent="true">
<Button android:layout_width="wrap_content"
android:layout_height="50px" android:id="#+id/setalarm"
android:layout_centerInParent="true" android:text="#string/setalarm" />
</RelativeLayout>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/imgfile"
android:text="Enter Distance" />
<Button
android:id="#+id/okbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/textView1"
android:text="OK" />
<EditText
android:id="#+id/radius"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/imgfile"
android:layout_alignTop="#+id/okbutton" />
</RelativeLayout>
This image should make the problem easy to understand
http://i39.tinypic.com/r8t64l.jpg
Try to change the TextView in your Code to EditText.
Button okbutton = (Button) findViewById(R.id.okbutton);
okbutton.setClickable(true);
EditText radius = (EditText) findViewById(R.id.radius);
okbutton.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
i=radius.getText().toString();
}
});
try this....
by mistake you have puted any other view over your edit-text; jus go to your xml file and open Graphical layout, then find that view using mouse-pointer by clicking on that part in which your can not see the text in your shown picture, by double-clicking on that part you can goto xml, and jus remove that view from your xml