android-button

Spinner on Button click not responding to Click events:

走远了吗. 提交于 2019-12-12 06:48:51
问题 I have a spinner which drops down when a button is clicked. But when I am trying to set onItemSelectedListener, it is not taking the click events. spnrLocation.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View arg1, int arg2, long arg3) { System.out.println("location clicked" + arg2); edtLocation.setText(parent.getItemAtPosition(arg2).toString()); System.out.println("wfefe" + parent.getItemAtPosition(arg2).toString()); }

Mimicking Material-design raised button style, trouble with Stackoverflow solution

只谈情不闲聊 提交于 2019-12-12 05:17:33
问题 I'm struggling with the top answer here: How to mimic the Material-design raised button style, even for pre-Lollipop (minus the special effects)? I made a mock program with the bare essentials listed by @spierce7 In gradle: compile "com.android.support:appcompat-v7:24.1.1" // (24.2.1 in my case) In styles.xml: <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> In Android Manifest: android:theme="@style/AppTheme" My Activity extends AppCompatActivity My button is an

EditText And Buttons in ListView Android

孤街醉人 提交于 2019-12-12 04:55:55
问题 I have created custom ListView which is having two TextViews , Two Buttons and one EditText , My problem is: 1) Edit text is loosing control even after adding android:descendantFocusability="beforeDescendants" to root layout and beforeDescendants blocks onItemClick and onClick of buttons 2) If I add android:descendantFocusability="BlocksDescendants" in root layout then onItemClick of list and onClick of buttons start working but EditText become untouchable even after touching edittext

Using a background drawable selector on custom button

[亡魂溺海] 提交于 2019-12-12 04:35:33
问题 I am extending "Button" to create a custom button which I am adding extra functionality to -- and currently, the background drawable is not changing on touch. Here is some sample code that shows what I am currently doing: /src/CustomButton.java public class CustomButton extends Button { public CustomButton(final Context context) { this(context, null); } public CustomButton(final Context context, final AttributeSet attrs) { this(context, attrs, 0); } public CustomButton(final Context context,

Adding margins to button object programatically

余生长醉 提交于 2019-12-12 02:57:48
问题 Need to set left margin to a button object programatically. This is the code segment: RelativeLayout rl = (RelativeLayout) findViewById(R.id.for_button); MarginLayoutParams ml = new MarginLayoutParams(-2,-2); ml.setMargins(5, 0, 0, 0); Button btn = new Button(this); btn.setText("7"); btn.setTextColor(Color.WHITE); btn.setBackgroundResource(R.drawable.date_button); rl.addView(btn,ml) I also tried btn.setLayoutParams(ml); rl.addView(btn); Whats the big problem. Or is there any alternative way?

android - overriding back button causes volume buttons stop working

给你一囗甜甜゛ 提交于 2019-12-12 01:58:46
问题 I'm trying to override Back button to stop an audio player and close media player activity, but I noticed that volume buttons are not working anymore. I imagine there is a mistake in overriding code. PS. in my MediaController I override hide() method to always show controls. mediaController = new MediaController(this) { @Override public void hide() { // TODO Auto-generated method stub //do nothing } @Override public boolean dispatchKeyEvent(KeyEvent event) { if(event.getKeyCode() == KeyEvent

Modifying button height dynamically in upward direction

瘦欲@ 提交于 2019-12-12 00:50:31
问题 I'm trying to create graph-like structure using buttons. I want to modify the height of these buttons dynamically based on the value of seek bar. I'm able to implement this as shown in this screen shot 1. But the problem is buttons grows in height in downward direction (which is their default behavior). How do I make buttons grow upward as shown below? Xml <Button android:id="@+id/btnGraph" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id

How to create Button to control background sound.

ε祈祈猫儿з 提交于 2019-12-12 00:13:28
问题 I'm trying to add background music to my application. All I want is the sound should played on pressing the btnoptn Button and its text transitions into the "music off". The music should continue on any Activity until the settings page is returned to and the same Button is pressed again. The music then stops and the Button text changes to "music on". This my code so far: package hello.english; import hello.english.R; import android.app.Activity; import android.content.Intent; import android

How to add two Buttons next to each other? (Buttons with background image, not ImageButtons)

可紊 提交于 2019-12-11 18:17:28
问题 I want two buttons next to each other like this: [ Use ] [ Cancel ] (These are just buttons with background images, NOT ImageButtons) But the result is strange, the first button fills all the space, in the linear layout like this: [..........Use...........] and the Cancel button is not shown. The layout_width are "wrap_content" for both buttons, and the linear layout's orientation is horizontal whats the problem? Got a code: <LinearLayout android:layout_width="fill_parent" android:orientation

Android button shape drawable margin

前提是你 提交于 2019-12-11 16:49:28
问题 Im styling a button using a shape drawable, this causes the button to over expand a little or lose it's margin so it doesnt align well with the other buttons. any idea why: This is my layout code: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/LinearLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android