android-button

How can I force my checkbox's text to not wrap?

别来无恙 提交于 2019-12-10 21:09:04
问题 This is what my LinearLayout (horizontal) row looks like: I want the text of the checkbox to be on one line; The buttons don't have to be that wide - they'll still have plenty of space with the checkbox text lengthened a bit. What in my XML: <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <CheckBox android:id="@+id/ckbxAllow_New_Items" android:layout_width="0dip" android:layout_height="fill_parent" android:layout_weight=

How to programmatically make a small button wrap small text

社会主义新天地 提交于 2019-12-10 16:50:33
问题 I want to make small buttons, So far I have made the text small but there is still alot of space around the text. I have tried the code below: LinearLayout layout = (LinearLayout) view.findViewById(R.id.fragment_dds_tag_linearLayout); Button txtName = new Button(getActivity(), null, android.R.attr.buttonStyleSmall); txtName.setClickable(false); txtName.setTextSize(5); txtName.setMaxLines(1); txtName.setMaxHeight(40); txtName.setMinHeight(0); txtName.setLayoutParams(new ViewGroup.LayoutParams

Overriding text color for buttons not working

有些话、适合烂在心里 提交于 2019-12-10 16:28:54
问题 I've created a custom theme for a button bar using buttonBarStyle on each button and buttonBarButtonStyle on the layout. It works fine, but i want to change the text color for the buttons, but it still takes the default color (@android:color/primary_text_holo_light) My code is: <style name="ButtonBarTheme" parent="AppTheme"> <item name="buttonBarStyle">?android:attr/buttonBarStyle</item> <item name="buttonBarButtonStyle">?android:attr/buttonBarButtonStyle</item> <item name="android:textColor"

How to create a transparent Button?

拈花ヽ惹草 提交于 2019-12-10 14:55:32
问题 I am trying to create a transparent Button. In details I set the background's button with an image and I would like to modify the transparency of the button in order to see the background layout's color. 回答1: you can use setAlpha() method to your Button. Using button.setAlpha(0.0) from your java code, will make your button fully transparent. Or you can also use it in your layout xml. Inside your <Button /> tag use the following attribute: android:alpha="0" 回答2: If you use ?android:attr

How to change text background color of a button in Android?

女生的网名这么多〃 提交于 2019-12-10 14:13:46
问题 I have searched a lot but I haven't found what I want. What I’m planning to do is to change the background colour of text on a button. I’m not interested in changing the colour on click. I just want to change the background of the text on a button. Thank you. Edit: This is a sample. I want to change the black colour if it possible. 回答1: created this with the help of this,i have correctly positioned the textview on button to acheive this kind of aout put: <Button android:id="@+id/button1"

how to create button dynamically and add click event to button in android

穿精又带淫゛_ 提交于 2019-12-10 12:24:06
问题 I need to add a button to the activity in android. And when I click this button I need to get which checkbox is checked and unchecked.My code is package com.example.a; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.widget.Button; import android.widget.CheckBox; import android.widget.LinearLayout; import android.widget.ScrollView; import android.view.View.OnClickListener; public class MainActivity extends Activity { @Override protected void

ImageButton change background colour on click

主宰稳场 提交于 2019-12-10 12:20:01
问题 How I can make my ImageButton change its color when I click it? I want to do something like this : Button(Blue) -> Click -> Button(Red) -> Click -> Button(Blue) -> Click -> Button(Red) when I click it switch color and when I click again it goes back to original. I've tried to do like this: mTrashFlag = !mTrashFlag; ImageButton bt = (ImageButton)findViewById(R.id.trash_button); if(!mTrashFlag) { bt.setBackgroundColor(0x4CB8FB); } else { bt.setBackgroundColor(0xff0000); } but it didnt work. It

How can I LOOP over several Button Views?

China☆狼群 提交于 2019-12-10 11:11:48
问题 Say for example I define several buttons in my XML file and initially set them as disabled. <Button android:text="Off" android:id="@+id/Button0" android:enabled="false"> </Button> <Button android:text="Off" android:id="@+id/Button1" android:enabled="false"> </Button> <Button android:text="Off" android:id="@+id/Button2" android:enabled="false"> </Button> <Button android:text="Off" android:id="@+id/Button3" android:enabled="false"> </Button> Later on in my code I then want to enable ALL the

how to implement simple like button in listview of each item

[亡魂溺海] 提交于 2019-12-10 04:07:02
问题 I have certain entries in my list view item. There I have a simple "like button" (not facebook like button). You can see the above mentioned SCREENSHOT; for the reference. The moment I click on like button; i want the like button color to be changed and the like button color should remain same( changed on like ) when I'll login again. Also, all the entries must get filled in Database with cust_id, bus_id, Offer_id using json; that I know very well. When I again click on the same button(like

Create android buttons programmatically using XML layout as template

夙愿已清 提交于 2019-12-10 03:52:34
问题 I have a LinearLayout that contains a TextView, and always will. There will also always be at least one button located below the TextView, but there might be more than one under certain circumstances. I can successfully create and add as many buttons as I need programmatically. I can also successfully set whatever appearance related parameters/options that I require for these buttons programmatically. The problem is that I don't know how to tell a programmatically created button that it