android-button

How to set Different String in a Textview in Fragment while clicking different Button?

拟墨画扇 提交于 2019-11-30 09:52:50
问题 I'm new to Android app programming. I have two Fragments - fragmentA.xml and fragmentB.xml . In fragmentA there are two Buttons - Button One (id: btnOne ) and Button Two (id: btnTwo ). In fragmentB there is TextView (id- textView ) In fragmentB java class there are two String - string1 and string2 Both buttons refers to fragmentB . I want two set the textView text to string1 when I press Button One and string2 when I press Button Two. How can I do that? I was using following code in fragmentB

AppCompatButton backgroundTint API < 21

不羁的心 提交于 2019-11-30 07:19:41
问题 I want to use ripple effects on Buttons. AppCompat v22.1 added AppCompatButton and new functionalities to AppCompat tinting. My Layout: <android.support.v7.widget.AppCompatButton android:id="@+id/add_remove_button" android:layout_width="match_parent" android:layout_height="match_parent" android:backgroundTint="@color/primary" android:textColor="@android:color/white" android:text="Remove" /> On my API 22 test device the ripple effect works perfectly, but i'm coding for API 11 and unfortunately

How to set Style for a button in Android?

纵饮孤独 提交于 2019-11-30 07:06:27
问题 I have defined the below files in res folder. styles_apptheme.xml <?xml version="1.0" encoding="utf-8"?> <!-- Generated with http://android-holo-colors.com --> <resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="ButtonAppTheme" parent="android:Widget.Holo.Light.Button"> <item name="android:background">@drawable/apptheme_btn_default_holo_light</item> </style> </resources> themes_apptheme.xml <?xml version="1.0" encoding="utf-8"?> <!-- Generated with http:/

Android: Make a button with triangle shape using xml definitions (drawable)

放肆的年华 提交于 2019-11-30 06:58:55
问题 I want create this using button (TextView) by using XML definiton: In layout of the Activity I have: <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/button_arrow" <!-- I NEED IMPLEMENT THIS --> android:clickable="true" android:drawablePadding="7dp" android:gravity="center" android:drawableLeft="@drawable/music_cloud" android:onClick="exportSong" android:padding="20dp" android:text="@string/export_upload" android:textAppearance="

Android: Drawing a button as a spinner

流过昼夜 提交于 2019-11-30 06:54:07
问题 I have a custom android view that extends 'Button' and acts as a multi-level spinner - when it is pressed it displays a series of spinner-like dialogs that allow a user to refine their selection. In this case, it allows the user to select the day, then hour, then minute (in 5 min intervals) that they want a pickup to occur. When the dialog is not active, a text description of the current selection is shown on the button. I want to visually indicate that the user can change the selection by

Android button background color

我与影子孤独终老i 提交于 2019-11-30 06:19:11
问题 I am trying to set the background color of a button in my app and I am unable to achieve the result that I want... The color that I am trying to set is holo_green_light(#ff99cc00) . In order to do it, I am using setColorFilter(0xff99cc00, PorterDuff.Mode.MULTIPLY); The color that I get is not the holo_green_light but a mix of lightgrey and holo_green_light . I have tried using the LightingColorFilter without much success. Is there a way to do it programatically, so that the button appears

Rounded corners on material button

痴心易碎 提交于 2019-11-30 04:33:48
I'm following the tips from questions like this to create a button style like suggested on Material Design. However, I need to change the corner radius and haven't been able to do so by inheriting Widget.AppCompat.Button.Colored style and setting the radius parameter. How can I have the same style but with rounded corners? You need to inherit that style. Add into your styles.xml: <style name="AppTheme.RoundedCornerMaterialButton" parent="Widget.AppCompat.Button.Colored"> <item name="android:background">@drawable/rounded_shape</item> </style> Add file drawable/rounded_shape.xml: <shape xmlns

Button to go back to MainActivity

↘锁芯ラ 提交于 2019-11-30 03:09:27
I want to create a button that would lead the user straight back to main activity which doesn't have the android name="com.example.example". It has android.intent.etc... How can I reference my button to go back to this activity? zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz Lets say your main activity is called Main.java. btnBack.setOnClickListener(new OnClickListener(){ private void onClick(){ Intent intent = new Intent(currentActivity.this, Main.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } }); use startActivity(intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)); Sometimes

NullPointerException on button's OnClickListener

一个人想着一个人 提交于 2019-11-30 02:37:08
问题 I'm writing an Android game app for an Artificial Intelligence semester project. I'm getting a NullPointerException on Line 38 of the main class, which is the setOnClickListener for the new game button from the launch screen. Relevant sections Class WW3Activity: public class WW3Activity extends Activity { public boolean DebugMode = false; private String buildMenuEmplacement = ""; //[Initialization] Called when the app is first launched @Override public void onCreate(Bundle savedInstanceState)

In Android, how to make Login button disable with respect to EditText?

 ̄綄美尐妖づ 提交于 2019-11-30 02:27:57
If EditText is empty then Login Button has to be disabled. And if EditText has some texts then Login Button has to be enabled. Well you can see this method on Instagram Login. Both fields are empty, Sign in Button is DISABLED. Here Password field is empty, so still Sign in Button is DISABLED. Here both Username and Password field is not empty, So Sign in Button is ENABLED. how to achieve these steps?? here is my code and it doesn't work.. EditText et1,et2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login