android-button

Add a button to the top right of action bar

十年热恋 提交于 2019-12-02 22:22:05
Is there a way I can add a button to the top right of my ActionBar , like where the default settings Button is? I removed the settings Button but I'd like to add a custom Button in it's place. Android You can add a button by editing/create the menu xml file: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/action_name" android:icon="@drawable/you_resource_here" android:title="Text to be seen by user" app:showAsAction="always" android:orderInCategory="0"/> </menu>

implement android:src=“@drawable/image” programmatically in Android

女生的网名这么多〃 提交于 2019-12-02 21:46:27
I am trying to set the foreground image on an image button. After some research, I came across this code sample: <ImageButton android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/icon"/> My query is how to actually implement android:src in code. Try this: ImageButton btn = (ImageButton)findViewById(R.id.button1); btn.setImageResource(R.drawable.newimage); where newimage is the image name in drawable folder. EDITED try this: ImageButton btn = (ImageButton)findViewById(R.id.button1); btn.setImageBitmap(bm)

how to make a capsule shape Button in android?

半世苍凉 提交于 2019-12-02 18:31:47
I want to make a button exactly like in this image I want to use a xml file that will used to produce such button. Can anyone tell me how to do that? finally I found the way to do it with xml file. here is the code of the xml file that gave me the capsule shape button. <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <corners android:bottomLeftRadius="30dp" android:bottomRightRadius="30dp" android:radius="60dp" android:topLeftRadius="30dp" android:topRightRadius="30dp" /> <solid android:color="#CFCFCF" />

How to rotate views on orientation change without recreating layout?

柔情痞子 提交于 2019-12-02 18:22:05
This question has been asked before here but its answer is incorrect. I would like to rotate some views on screen orientation change, but I want to keep the layout unchanged. They should be rotated 90, 180, 270 or 360 degrees according to the current orientation ( SCREEN_ORIENTATION_LANDSCAPE , SCREEN_ORIENTATION_PORTRAIT , SCREEN_ORIENTATION_REVERSE_LANDSCAPE , SCREEN_ORIENTATION_REVERSE_PORTRAIT ). This is what I want to achieve: The answer in the link I mentioned stated that I should create a new different layout in layout-land . Clearly, this is not what I want. I don't want to recreate

Button next and prev not working

穿精又带淫゛_ 提交于 2019-12-02 16:56:17
问题 This is my Linear Layout <?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:background="@android:color/white" android:gravity="center_horizontal" android:orientation="vertical" > <AutoCompleteTextView android:id="@+id/autoCompleteTextView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight=".16" android:ems=

Android RadioButton allow more than one to be check

五迷三道 提交于 2019-12-02 16:29:52
问题 I have a radiogroup with about 30 radiobuttons . I have looked around on stackoverflow and found a few posts about the accidental allowing of multiple radiobuttons to be checked. They were not in a radiogroup, or had problems with their id . https://stackoverflow.com/questions/8265034/android-radiogroup-checks-more-than-one-radiobuttonhttps://stackoverflow.com/questions/17157705/radiogroup-allows-multiple-radiobuttons-to-be-selected How can I purposefully allow 3 radiobutton to be selected at

Button in ListView using ArrayAdapter

你说的曾经没有我的故事 提交于 2019-12-02 16:16:33
问题 I have a ArrayAdapter which is populated using a POJO class. The listview comprises of 2 layout. 1 is for a menuitem and one is for the category. The Listview with seperator is fine. Later I tried to add a button in each menuitem row to edit the details in it. Here I have a problem when I tried to get the position of the row where the button is clicked. I tried to display the position using the log. 1. If there is less number of rows and there is no need to scroll. the the log shows the

How to add functionality to buttons of each of the recyclerview items?

北慕城南 提交于 2019-12-02 16:09:26
问题 I am writing an android code, wherein on clicking a button on the recyclerview, it should direct it to some other activity. The program should redirect the control to different activities for each of the recyclerview items. I have successfully added buttons to the template of the activity, however, I am not able to understand how to add functionality to each of the buttons. I am enclosing herewith the the different files that I have included in the project. It would be very helpful if someone

Button in ListView using ArrayAdapter

房东的猫 提交于 2019-12-02 10:22:34
I have a ArrayAdapter which is populated using a POJO class. The listview comprises of 2 layout. 1 is for a menuitem and one is for the category. The Listview with seperator is fine. Later I tried to add a button in each menuitem row to edit the details in it. Here I have a problem when I tried to get the position of the row where the button is clicked. I tried to display the position using the log. 1. If there is less number of rows and there is no need to scroll. the the log shows the correct position. 2. If i have more rows running into pages then the position in my log is not correct.

Android RadioButton allow more than one to be check

霸气de小男生 提交于 2019-12-02 09:11:29
I have a radiogroup with about 30 radiobuttons . I have looked around on stackoverflow and found a few posts about the accidental allowing of multiple radiobuttons to be checked. They were not in a radiogroup, or had problems with their id . https://stackoverflow.com/questions/8265034/android-radiogroup-checks-more-than-one-radiobuttonhttps://stackoverflow.com/questions/17157705/radiogroup-allows-multiple-radiobuttons-to-be-selected How can I purposefully allow 3 radiobutton to be selected at a time and implement a listener for those three selected. I suspect I am doing something wrong. Is