android-button

How to put two buttons on same line in Android

限于喜欢 提交于 2019-12-18 14:56:18
问题 How can I place two buttons on the same line in my login layout on my Android application? 回答1: Just make a linear layout.Set the orientation to horizontal and add two buttons.Its ready you will get what you want.Before posting such questions try googling you will get the answer for sure.This piece of code will help you. <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout

setBackgroundColor in android

人走茶凉 提交于 2019-12-18 12:34:57
问题 In this simple game I want to change the background color of the button that I press. But I get the following result, the buttons appearance becomes not good (the shape becomes different): pressedButton.setBackgroundColor(Color.RED); Is there a nicer way to do that? Thanks. [Edit: my full code] package com.example.xo_game; import android.os.Bundle; import android.app.Activity; import android.graphics.Color; import android.view.Menu; import android.view.View; import android.widget.Button;

How to limit list items display in ListView by 10 and next 10after clicking next button

限于喜欢 提交于 2019-12-18 11:56:45
问题 i have a listview with 100 items and i want to display first 10 items and on click of next button i have to display next 10 ie.,from 11 to 20, i have the code for getting first 10 items public int getCount() { return 10; } but how to get next 10 items alone and so on. any idea 回答1: One way to do this is, 1) Don't populate your ArrayList with all the data. Instead keep them in a separate ArrayList ( al1 ) and use an ArrayList ( al2 ) with max 10 values to use with your BaseAdapter. 2)

Is any difference between a MaterialButton and a simple Button?

≯℡__Kan透↙ 提交于 2019-12-18 09:03:33
问题 If I set Theme.MaterialComponents.Light as my main theme, will be any difference between these two buttons if I use them in an xml layout? <Button /> <com.google.android.material.button.MaterialButton /> As I saw they behave both as MaterialButtons. If I want to get the behavior of the old plain button, I have to use: <androidx.appcompat.widget.AppCompatButton /> Thanks in advance! 回答1: If you are using a Material Theme there is no difference between <Button /> and <com.google.android

How do I make my button which is fixed at the bottom of a layout scroll, once the recyclerview on top grows in size

为君一笑 提交于 2019-12-17 21:10:40
问题 I have a very basic yet difficult issue where I have a button fixed at the bottom of the view, but below recyclerview container. Once the container size grows, I want the button to go below the recyclerview (scrollable) instead of being fixed at the bottom of the view.Is there a way to achieve this? I have looked online for a couple of ideas but didn't find anything quite like it yet. i am basically using <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout

Android 5.0 - ProgressBar cannot be displayed over a Button

耗尽温柔 提交于 2019-12-17 19:58:14
问题 I think the title is pretty explicit about my problem... So here is my layout : <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <Button android:id="@+id/button_action" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Login" /> <ProgressBar android:id="@+id/progress_bar" android:layout_width="50dp" android:layout_height="50dp" android:layout_centerInParent="true"/> </RelativeLayout> On android SDKs < 21, no problem

How can i position a button in between two layouts

社会主义新天地 提交于 2019-12-17 19:55:04
问题 I am trying to position a button in between two layouts. Also, I don't want to have to do this with a margin if I can help it, when you start dealing with different screen sizes margin breaks down. (In this image, I am trying to position the green button in between two layouts) <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_height="fill_parent" android:layout_width="fill_parent"

Create Button with rounded corners in android

喜夏-厌秋 提交于 2019-12-17 18:41:14
问题 I'm trying to create a button which looks as in the image above. Initially my idea was to create a 9 patch and set it as the button background. But since, this is a plain button, i think we can somehow draw this without using any images. The button background color is #0c0c0c The border color is #1a1a1a The text color is #cccccc I found a similar question on SO but that creates a gradient - Android - border for button 回答1: The Android Developer's Guide has a detailed guide on this: Shape

How is using OnClickListener interface different via XML and Java code? [duplicate]

核能气质少年 提交于 2019-12-17 10:08:49
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Difference between OnClick() event and OnClickListener? I'm semi-new to Android development and when I first started I tried to avoid using the xml layout by any means necessary so some of my earlier projects involve buttons that explicitly create an OnClickListener and implement it as an anonymous inner class. Such as - final Button button = new Button(this); button.setText("Click to change second line of text"

Rounded Button in Android

自作多情 提交于 2019-12-17 07:03:41
问题 I want to create rounded buttons in an Android program. I have looked at How to create EditText with rounded corners? What I want to achieve is: Rounded Edge Buttons Change Button background/appearance on different states (Like Onclick, Focus) Use my own PNG for the background and not create a shape. 回答1: You can do a rounded corner button without resorting to an ImageView. A background selector resource, button_background.xml : <?xml version="1.0" encoding="utf-8" ?> <selector xmlns:android=