android-button

Lollipop capitalizes Buttons' text in my app

冷暖自知 提交于 2020-01-10 04:22:04
问题 I am expreiencing a strange problem with my application. When I am testing it on a real device (with Android 4.4.4) all my Buttons' text fields look how I wanted (lower case letters). But when I launch my application on an emulator (Android 5.0.1) all Button texts fields are capitalized. What is the reason of such behaviour? Some example Buttons from my app: Example Button 1: <Button android:id="@+id/button5" android:layout_width="match_parent" style="?android:attr/borderlessButtonStyle"

How to make onTouch works like onTap in Android?

夙愿已清 提交于 2020-01-07 02:44:11
问题 I've implemented an OnTouchListener in my MapActivity and of course I had to override the onTouch() method. I want it to fire only when I tap on the map - otherwise I can't even move the map. Here's my onTouch method: @Override public boolean onTouch(View v, MotionEvent e) { if (e.getAction() == MotionEvent.ACTION_DOWN) { // SOME ACTIONS ... } return true; } 回答1: use: e.getAction() == MotionEvent.ACTION_UP and: e.getAction() == MotionEvent.ACTION_MOVE if there was and ACTION_UP event after

public static hashmap clear and put not work properly [closed]

扶醉桌前 提交于 2020-01-05 11:56:27
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . At first I click the “mn_column” button, then works properly. But I go back and click again “mn_column” or “mn_blog” then it show flowing error : 08-10 02:30:16.441: E/AndroidRuntime(1098): FATAL EXCEPTION: main 08-10 02:30:16.441: E/AndroidRuntime(1098): Process: com.sams.main.news, PID: 1098 08-10 02:30:16.441

Button with selector for background color - when clicked the background color is extending out of the button

…衆ロ難τιáo~ 提交于 2020-01-05 08:43:27
问题 To begin with.. the button is added dynamically through code and hence cannot apply the styles in xml. I have few buttons in my activity and i am using a selector to change the background color. The button also has a "shape" attached to it, for border. image_border.xml <?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" > <solid android:color="@color/dark_grey" /> <stroke android:width="4dp" android:color="@color/light_grey" /> <padding

Button OnClickListener not working

和自甴很熟 提交于 2020-01-03 19:17:11
问题 I have a button, when I click a dialog box appears. The problem is, the setOnClickListener is not responding to my button. Here is my Java code: Button b1 = (Button) findViewById(R.id.button1); b1.setOnClickListener(usage); b2 = (Button) findViewById(R.id.button2); b2.setOnClickListener(price); b3 = (Button) findViewById(R.id.button3); b3.setOnClickListener(new OnClickListener() { public void onClick(View v) { System.out.println("Button3"); mainDialog3 = new Dialog(Advice.this); mainDialog3

Button OnClickListener not working

倖福魔咒の 提交于 2020-01-03 19:17:03
问题 I have a button, when I click a dialog box appears. The problem is, the setOnClickListener is not responding to my button. Here is my Java code: Button b1 = (Button) findViewById(R.id.button1); b1.setOnClickListener(usage); b2 = (Button) findViewById(R.id.button2); b2.setOnClickListener(price); b3 = (Button) findViewById(R.id.button3); b3.setOnClickListener(new OnClickListener() { public void onClick(View v) { System.out.println("Button3"); mainDialog3 = new Dialog(Advice.this); mainDialog3

Android 3D button text position

天大地大妈咪最大 提交于 2020-01-01 15:05:21
问题 How to change text position for different button states? On image you can see how its look like now: drawable <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:state_pressed="true"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:top="4dp"> <shape android:shape="rectangle"> <solid android:color="#DCDBDB" /> <corners android:radius="7dp" /> <stroke android:width="1dp" android:color="

Add a button to the top right of action bar

元气小坏坏 提交于 2019-12-31 13:13:06
问题 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. 回答1: 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"

how to change size of button dynamic in android

China☆狼群 提交于 2019-12-29 05:37:06
问题 I try setWidth() and setheight() method but it not work 回答1: Try using LayoutParams. For example button.setLayoutParams (new LayoutParams(50, LayoutParams.WRAP_CONTENT) 回答2: For me works perfect this: ViewGroup.LayoutParams params = myButton.getLayoutParams(); //Button new width params.width = 400; myButton.setLayoutParams(params); 回答3: I found this to be the best solution because it also allows the button to be repositioned at the same time by simply changing its margin: int buttonWidth =

How do I change the text color of a Button?

佐手、 提交于 2019-12-29 04:29:19
问题 How do I change the text color of a Button? 回答1: try this: button.setTextColor(getApplication().getResources().getColor(R.color.red)); //TAKE DEFAULT COLOR or button.setTextColor(0xff0000); //SET CUSTOM COLOR or button.setTextColor(Color.parseColor("#ff0000")); and in xml : <Button android:id="@+id/mybtn" android:text="text textx " android:layout_width="fill_parent" android:layout_height="wrap_content" android:textStyle="bold" android:textColor="#ff0000" /> <-- SET TEXT COLOR HERE --> 回答2: