Get listview item position on button click

do you execute this btnNxt = (Button) findViewById(R.id.btnNext); btnNxt.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { //Here I need to get that position }); inside the getView method? if so it’s very easy btnNxt = (Button) findViewById(R.id.btnNext); btnNxt.setTag(position); btnNxt.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { int position=(Integer)arg0.getTag(); });

How do I set a different color for the pressed state of the button?

create xml file using the button image like this with mybutton.xml in drawable folder <?xml version=”1.0″ encoding=”utf-8″?> <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:state_pressed=”true” android:drawable=”@color/blue” /> <item android:state_focused=”true” android:drawable=”@color/gold” /> <item android:drawable=”@color/grey” /> </selector> and use this in button xml code android:background=”@drawable/mybutton” add those color codes in the resource–>values–>colors.xml like this <?xml version=”1.0″ encoding=”utf-8″?> <resources> <color name=”blue”>#0066cc</color> <color … Read more

Android EditText and Button on same line

Does it have to be Relative Layout? I would suggest the following: set EditText layout_width to fill_parent and its layout_weight to 1, something like this: <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_height=”wrap_content” android:orientation=”horizontal” android:layout_width=”fill_parent”> <EditText android:text=”@+id/EditText01″ android:id=”@+id/EditText01″ android:layout_height=”wrap_content” android:layout_weight=”1″ android:layout_width=”fill_parent”> </EditText> <Button android:text=”@+id/Button01″ android:id=”@+id/Button01″ android:layout_width=”wrap_content” android:layout_height=”wrap_content”> </Button> </LinearLayout>

How do I change the text color of a Button?

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 –>

how to make a capsule shape Button in android?

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” /> <padding android:bottom=”0dp” android:left=”0dp” android:right=”0dp” android:top=”0dp” /> <size android:height=”60dp” android:width=”270dp” /> </shape>

How to mimic the Material-design raised button style, even for pre-Lollipop (minus the special effects)?

Updated Answer: It is recommended that you rely on Google’s appcompat library to backport material design styles to your app. It seems to no longer backport the raised button (instead using flat buttons), but still adequately backports a button that matches the material design style. It is my recommendation that you go with this approach. … Read more

How do I set the disabled color of a button with AppCompat?

You aren’t using the Widget.AppCompat.Button.Colored style correctly. You’re using a parent style (Widget.AppCompat.Button.Colored), but applying it as a theme. This effectively means that the Widget.AppCompat.Button.Colored part is being ignored entirely and you are instead just changing the default color of the button (which works, but doesn’t handle the disabled case). Instead, you should use a … Read more

Can’t change background color on MaterialButton without change colorAccent

1st Solution You can use app:backgroundTint to change back ground color of MaterialButton <com.google.android.material.button.MaterialButton android:id=”@+id/bittrexJsonViewButton” android:layout_width=”0dp” android:layout_height=”@dimen/min_height” android:layout_marginStart=”@dimen/half_default_margin” android:layout_marginEnd=”@dimen/half_default_margin” app:backgroundTint=”@android:color/holo_orange_dark” android:text=”@string/json_view” app:layout_constraintBottom_toBottomOf=”@+id/binanceJsonViewButton” app:layout_constraintEnd_toEndOf=”parent” app:layout_constraintStart_toEndOf=”@+id/binanceJsonViewButton” app:layout_constraintTop_toTopOf=”@+id/binanceJsonViewButton” /> 2nd Solution MaterialButton uses colorPrimary as background when button is in active state and colorOnSurface when disabled. So, you can define it in your theme and apply it on … Read more