I have a linear layout in which each row is inflated programatically and I want the rows to behave like the ListView when clicked on. That is, I want the row to highlight in the exact same way/colour that the default ListView does. How would I go about doing this?
相关问题
- How can I create this custom Bottom Navigation on
- Illegal to have multiple roots (start tag in epilo
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Creating XML Elements without namespace declaratio
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Get Attribute Value From Simple XML Using JQuery /
Ok I have finally figured out how to do this...basically it is done using a selector like the color selector linked by style except instead of 'color' use a drawable for the states and you can refer to the default list drawable that is used in ListView by this:
and using this xml as the background for my View.
All the public default drawables can be found here: http://developer.android.com/reference/android/R.drawable.html
if you still have a problem with that then please remember that some of UI elements are not clickable (RelativeLayout), so you have to add one more line:
This might be a good place to start looking.
Although, i would advise you to use the ListView itself, rather than implementing it again.
I was able to do the same with a text view that I wanted to behave like a list item by using:
To your listview set property
and this test color set any transparent color you like. you can create any transparent color by using hex transparent color