<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/hello" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="xyz" />
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
I have an XML layout as above and when I click that xyz button I want to launch my application "Sample App" which will show a dialog.
I have enabled "talkback" application from settings ->Accessibility.
Then once I click xyz button, talkback app is saying "alert.." but its not saying "alert + dialog title".
But if i start a dialog in my application then its saying the dialog title correctly.
Declare Your activity in manifest like..
<activity
android:name=".ActivityName"
android:theme="#android:style/Theme.Dialog" >
Related
The image above is my current activity with a dialog fragment. as you can see dialog is in the middle of the screen but it want it to look something like in google maps where when I click on the button the dialog appears near the button:
=>
As you can see in google maps the dialog is not in the middle its near the selected button. This is my code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/edit_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/lbl_your_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your name" />
<EditText
android:id="#+id/txt_your_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone"
android:inputType="text" />
</LinearLayout>
Which looks like this:
As you can see when I edit my dialogfragment the edittext and textview are on the top of the screen but for some reason when I deploy the app they are in the middle.
I am working on widget project and when I touch the widget a new activity that is styled like a dialog box. The main activity opens and the dialog styled activity appears and when I touch the main activity the dialog styled activity disappears.
1) Is there a way to disable the activity? or
2) Is there away to open the dialog styled activity without opening the activity?
Here is my onReceive Class in my BroadcastReceiver
public void onReceive(Context context, Intent intent)
{
Log.i(TAG,"In onReceive");
if(intent.getAction().equals(INTENT_ACTION))
{
Intent mIntent = new Intent(context,sendActivity.class);
mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(mIntent);
}
}
Dialog Styled Actvity
<?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"
android:focusable="true"
android:focusableInTouchMode="true">
<ImageView
android:id="#+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp" />
<TextView
android:id="#+id/tvdialogTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFF"
android:layout_toRightOf="#+id/image"/>
<TextView
android:id="#+id/tvStatus01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFF" />
<TextView
android:id="#+id/tvStatus02"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFF"/>
<Button
android:id="#+id/btnWidgetDialogCancel"
android:layout_width="100px"
android:layout_height="wrap_content"
android:text="Cancel"
android:layout_marginTop="5dp"
android:layout_marginRight="5dp"
android:layout_below="#+id/image"
/>
</RelativeLayout>
Part of my Manifest
<activity
android:name="com.example.widget.sendActivity"
android:theme="#android:style/Theme.Dialog"
android:excludeFromRecents="true">
</activity>
Thanks in advance.
I used this line if anyone else is interested
this.setFinishOnTouchOutside(false);
I would like to align two buttons on the bottom of a relative layout that is wrapped inside of a linear layout.
I am unable to get the view favorites button to be on top of the search button. There is a big space as you can see in this image:
Here is my code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:text="#string/SearchRestaurantsCity"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/tvRestaurantSearchCity" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/etRestaurantSearchCity" />
<TextView
android:text="#string/SearchRestaurantsState"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/tvRestaurantSearchState" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/etRestaurantSearchState" />
<TextView
android:text="#string/SearchRestaurantsCategories"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/tvRestaurantSearchCategories" />
<Spinner
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/spRestaurantSearchCategories" />
<RelativeLayout
android:id="#+id/InnerRelativeLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true">
<Button
android:text="#string/btnViewFavoriteRestaurants"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/btnViewFavoriteRestaurants"
style="#style/ButtonText"
android:padding="5dp"
android:layout_below="btnSearchRestaurants" />
<Button
android:text="#string/btnSearchRestaurants"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/btnSearchRestaurants"
style="#style/ButtonText"
android:layout_alignParentBottom="true"
android:padding="5dp" />
</RelativeLayout>
There are 2 things wrong with the XML.
For starters, you can't refer to the button btnSearchRestaurants before it's defined.
Secondly, you've defined btnSearchRestaurants to align-parent-bottom, and then tried to define that btnViewFavoriteRestaurants would be below that button. It should be above it (as per your description).
If you're trying to put the first button I can see inside RelativeLayout, I'd try to change the following line:
android:layout_below="btnSearchRestaurants" />
for this one:
android:layout_above="#+id/btnSearchRestaurants" />
Part of the space is reserved for all the elements of the layout I can see inside the LinearLayout,and the + is because the button btnSearchRestaurants is below so it is not created yet
I think the problem is at
android:layout_below="btnSearchRestaurants"
It should be
android:layout_below="#id/btnSearchRestaurants"
In your xml code I think you should correct this line
android:layout_below="btnSearchRestaurants"
as you want it to be above the Search Restaurants button it should be
android:layout_above="#id/btnSearchRestaurants"
I changed below to above for obvious reasons (you want it above the other button not below it) and added #id/ because you will be searching for the button id.
I wanted to make a button always set at the bottom of the page but will move so it is always shown. The main reason I want this is because when you click into an edit text field the keyboard will pop-up and hide the button. I would like the button to move so it sits above the keyboard when in a field and then will return to the bottom when the keyboard is hidden. Currently I am using a relative layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" android:background="#FFFFF0">
<RelativeLayout android:orientation="vertical"
android:id="#+id/titlebar1" android:background="#082386"
android:layout_width="fill_parent" android:layout_height="50dip"
android:gravity="center">
<ImageView android:src="#drawable/banner"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:scaleType="fitXY">
</ImageView>
</RelativeLayout>
<Spinner android:layout_height="wrap_content"
android:layout_below="#+id/titlebar1" android:layout_width="wrap_content"
android:id="#+id/NewUsedSpinner" android:prompt="#string/NewUsed_prompt"
android:layout_marginTop="15dip">
</Spinner>
<Spinner android:layout_height="wrap_content"
android:layout_below="#+id/NewUsedSpinner" android:layout_width="wrap_content"
android:id="#+id/MakeSpinner" android:prompt="#string/Make_prompt">
</Spinner>
<Spinner android:layout_height="wrap_content"
android:layout_below="#+id/MakeSpinner" android:layout_width="wrap_content"
android:id="#+id/ModelSpinner" android:prompt="#string/Model_prompt"></Spinner>
<Spinner android:layout_height="wrap_content"
android:layout_below="#+id/NewUsedSpinner" android:layout_width="wrap_content"
android:id="#+id/TrimSpinner" android:prompt="#string/Trim_prompt"></Spinner>
<Spinner android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="#+id/PriceSpinner"
android:layout_below="#+id/TrimSpinner" android:prompt="#string/Price_prompt"
android:layout_marginBottom="5dip"></Spinner>
<TextView android:text="Search within the radius of:"
android:layout_below="#+id/PriceSpinner" android:id="#+id/textView1"
android:layout_width="wrap_content" android:layout_alignLeft="#+id/FilterZip"
android:layout_height="wrap_content" android:textColor="#000"
android:layout_marginTop="5dip"></TextView>
<Spinner android:id="#+id/ZipSpinner" android:layout_width="120dip"
android:layout_below="#+id/textView1" android:layout_height="wrap_content"
android:prompt="#string/Zip_prompt"></Spinner>
<EditText android:layout_width="fill_parent"
android:layout_below="#+id/textView1" android:layout_toRightOf="#+id/ZipSpinner"
android:layout_height="wrap_content" android:text="Zip" android:id="#+id/FilterZip"
android:maxLength="5" android:numeric="integer"></EditText>
<Button android:layout_height="50dip" android:id="#+id/FilterSearchbtn"
android:layout_alignParentBottom="true" android:layout_width="fill_parent"
android:text="Search" android:layout_below="#+id/ZipSpinner"
android:background="#drawable/yellow_btn" android:textStyle="bold"></Button>
</RelativeLayout>
In your Android manifest you would add this to your activity:
<activity android:name=".YourActivity"
android:windowSoftInputMode="adjustResize"
Here's the official documentation: http://developer.android.com/resources/articles/on-screen-inputs.html
Maybe try alignParentBottom="true" on the button so that it will always be on the bottom, you'll have to fiddle with your layout.
(1) If we want to only adjust the screen without view which has (alignParentBottom="true") in relative layout then set below line in activity tag in manifest.xml
android:windowSoftInputMode="adjustPan"
(2) If we want to adjust the whole relative layout with the view which has (alignParentBottom="true") in relative layout then set below line in activity tag in manifest.xml
android:windowSoftInputMode="adjustResize"
(3) If we don't want to adjust the whole relative layout without the view which has (alignParentBottom="true") in relative layout then set below line in activity tag in manifest.xml
android:windowSoftInputMode="adjustPan|adjustResize"
(4) If we remove line android:windowSoftInputMode from the manifest.xml then it will behave like (2) option
How can I show in AlertDialog two EditText and 2 TextView?
custom_dialog.xml
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout android:orientation="horizontal"
android:id="#id/layout_root" android:padding="10.0dip"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Libellé"
android:id="#+id/Text_Libelle"
/>
<EditText android:id="#+id/Edit_Libelle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
/>
<EditText android:id="#+id/Edit_Url"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
/>
On click on button I want to show this interface in alert dialog.
You basically have the layout created so all you have to do is assign it to your custom dialog like so..
Set the custom layout to the dialog after initializing..
Dialog dialog = new Dialog(someContext);
dialog.setContentView(R.layout.customdialoglayout); //Set dialog view to custom layout
To wire up your handlers you will have to do something to the effect of..
EditText myText = (EditText)dialog.findViewById(R.id.Edit_Libelle);
http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog