android-selector

How to implement a CustomView with custom selector states?

梦想的初衷 提交于 2019-11-29 09:11:50
问题 I want to create a CustomView that displays an image. On click the view should change its state. There should be three states (off, set, notset) the view can represent. I want to do this with a selector in XML. It does not necesseraliy need to be a custom selector. I could reuse three states of the selector (it does not matter if the names of the state are different then). Is there a good way to achieve this? 回答1: Just in case your issue has not resolved itself yet. I do the changing of

How set ListView not clickable

女生的网名这么多〃 提交于 2019-11-28 22:31:45
I have this ListView that just needs to show data. So I don't want to make it clickable. First I've tried changing XML listview to: <ListView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:clickable="false" > But it didn't work. So to solve my problem I set through code: list.setSelector(android.R.color.transparent); but I can't believe there's no better solution. Any idea? Here it is, following the comment: One way to do so is: ListView.setOnClickListener(null); OR You can add android

How set ListView not clickable

时光毁灭记忆、已成空白 提交于 2019-11-27 14:22:06
问题 I have this ListView that just needs to show data. So I don't want to make it clickable. First I've tried changing XML listview to: <ListView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:clickable="false" > But it didn't work. So to solve my problem I set through code: list.setSelector(android.R.color.transparent); but I can't believe there's no better solution. Any idea? 回答1: Here

How to use selector to tint imageview in android

巧了我就是萌 提交于 2019-11-27 03:45:08
I want to tint my tabhost's icons using xml, instead of doing it programatically (I wasn't able to do that anyway)... So I found this thread on SO: Android imageview change tint to simulate button click That seems to be a pretty good solution, but I wasn't able to adapt it correctly in my project... I did the following changes: public class TintableImageView extends ImageView { private ColorStateList tint; public TintableImageView(Context context) { super(context); } //this is the constructor that causes the exception public TintableImageView(Context context, AttributeSet attrs) { super

How to use selector to tint imageview in android

痞子三分冷 提交于 2019-11-26 10:35:37
问题 I want to tint my tabhost\'s icons using xml, instead of doing it programatically (I wasn\'t able to do that anyway)... So I found this thread on SO: Android imageview change tint to simulate button click That seems to be a pretty good solution, but I wasn\'t able to adapt it correctly in my project... I did the following changes: public class TintableImageView extends ImageView { private ColorStateList tint; public TintableImageView(Context context) { super(context); } //this is the

Android customized button; changing text color

我是研究僧i 提交于 2019-11-26 09:34:22
I made a button that changes the background drawable on different states, this way: <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/btn_location_pressed" /> <!-- pressed --> <item android:state_focused="true" android:drawable="@drawable/btn_location_pressed"/> <!-- focused --> <item android:drawable="@drawable/btn_location"/> <!-- default --> The problem here is that I'm also trying to change the textColor as I do with the drawable but I'm not being able to. I already tried android:textColor and android:color

Android selector & text color

核能气质少年 提交于 2019-11-26 03:22:24
问题 I want a simple TextView to behave the way simple_list_item_1 in a ListView does. Here\'s the XML: <TextView xmlns:android=\"http://schemas.android.com/apk/res/android\" android:layout_height=\"wrap_content\" android:layout_width=\"fill_parent\" android:gravity=\"center\" android:focusable=\"true\" android:minHeight=\"?android:attr/listPreferredItemHeight\" android:textAppearance=\"?android:attr/textAppearanceLarge\" android:background=\"@android:drawable/list_selector_background\" />

Android selector & text color

可紊 提交于 2019-11-25 18:44:07
I want a simple TextView to behave the way simple_list_item_1 in a ListView does. Here's the XML: <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="fill_parent" android:gravity="center" android:focusable="true" android:minHeight="?android:attr/listPreferredItemHeight" android:textAppearance="?android:attr/textAppearanceLarge" android:background="@android:drawable/list_selector_background" /> Everything works except for the text color that (expectedly) doesn't change in focused state. How do I make it change to