I have android listview with custom adapter.I have implemented the AdapterView.OnItemClickListener . Onclick it launches a new fragment. Now all of that works, but the listview Item turns grey after click in the background.I need it to be transparent/white.
So I thought it must be in a selected state which I somehow have to disable.
This is what I have tried so far without any luck.
listview.setSelector(android.R.color.transparent);
listView.setFocusable(false);
listView.setActivated(false);
Other options such as
in onItemClick(){
view.setBackgroundColor(ContextCompat.getColor(getContext(),
android.R.color.transparent));
interesting this seems to be semi working as if I use color.red. I can see it getting red momentarily before the fragment dialog shows at that point I can see it turning grey again in the background.
Also the odd part is that this last piece of code i.e
view.setBackgroundColor(ContextCompat.getColor(getContext(),
android.R.color.transparent)
works in onItemLongPress. And it stays transparent as expected.
Related
http://www.coderzheaven.com/2011/07/18/customizing-a-spinner-in-android/
In this example above, before an item is selected it shows text and dropdown arrow on the right. When the user clicks it (displaymode = dropdown?) it shows the prompt with an arrow as well. This is the behavior I want my customer spinner to do, but it's not. Primarily I want the spinner to load with wtih the normal dropdown arrow as first item. The prmpt issue I can at least get text to appear if i set displaymode=dialog on the spinner. For this post I mostly would like to get the default item issue resolved first...
Info:
I do not have android theme on my app. My parent systel is AppTheme butno parent above that. I have custom spinner like so:
List<LanguageSelection> nativeLanguagesData = getSupportedLanguageList();
LanguageSelectionListAdapter nativeAdapter = new LanguageSelectionListAdapter (this, R.layout.fragment_language_selection, nativeLanguagesData);
nativeAdapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item);
Spinner uxNativeLanguageSpinner = (Spinner)findViewById(R.id.uxNativeLanguageSpinner);
uxNativeLanguageSpinner.setAdapter(nativeAdapter);
and for xml:
<Spinner android:id="#+id/uxNativeLanguageSpinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"
android:padding="0dp"
android:spinnerMode="dropdown"
android:prompt="#string/status_prompt"
android:layout_below="#id/uxNativeLanguageSelectLabel"
android:popupBackground="#android:color/transparent" />
Attached is what appears. I've scoured the internet trying to figure out why this thing doesn't show first item with arrow. I also have the android simple_spinner_dropdown_item.xml in my code base instead of referencing andorid.r.*. Any ideas? I'd like to get rid of my ugly label just above the spinner indicating the user needs to select something and instead use the common dropdown arrow on the first item. Just doesn't show when I create a custom spinner though. Again, the items in the list appear correctly it's just that i want the first item be something like in the link at the top where there is Select and iten and down arrow icon to the right indicating it's dropdown.
[http://tinypic.com/r/2r7927o/5][1]
And this is image link below shows exactly what I'm talking about. I circled in red the dropdown arrow I want to appear. I want my list to appear just like this and it except for the dropdown arrow. The actual list of items when clicked appear just fine...
tinypic.com/r/2ekj6mv/5 (sorry, can't hyperlink because i need 10 reps to post two links)
I wanted to achieve the same sort of functionality found in Google Now where you can tap the cards overflow icon and a menu appears next to it with options (shown here).
Does anyone know how to implement this sort thing to achieve the same style etc?
I think you can do this by placing a listview under your button, and set its visibility to invisible.
Then place an onclicklistener on your button to turn your visibility to visible.
I have following problem:
I want to create a toolbar, with general setting for device (TV) by adding view to window manager. My toolbar is visible in the bottom of screen and it is an overlay on currently selected application. It has following parameters/flags:
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT
-WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
-WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
-WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
-PixelFormat.TRANSLUCENT
When I click on the toolbar it is working fine.
When I click on the background, toolbar is still at foreground, and background application is working fine.
The problem starts, when I am populating ListView from my toolbar. With those parameters, onClick and onSelectItem listeners are not working on that ListView. When I remove FLAG_NOT_FOCUSABLE, listeners start to work, but I cannot use background application any more. I have to close my toolbar in order to get focus on the background.
Do you have any idea, how to make both ListView and background application responsiveness?
Thanks in advance, for every answer/
This is known issue with PixelFormat.TRANSLUCENT, try PixelFormat.TRANSPARENT
I'm developing an Android 2.2 application with a ListView.
I want to disable this:
I have a ListView with three list items. When I press over the first list and, without releasing, I move down through second item and third item. Then, when my finger is over the third item I release it. After that I see that all of them has a black background.
How can I disable this effect?
If you need more details, please tell me.
Use this in your ListView element inside your XML file:
android:cacheColorHint="#android:color/transparent"
However, if your app has a background that is a solid color, then set the cacheColorHint to that color, as having it set to transparent can lead to slow scrolling. For example, if I had a green background:
android:cacheColorHint="#0F0"
Use
android:cacheColorHint="#00000000"
as one of the ListView attributes. This will disable the color caching, which will stop doing this black thing.
Why does my Android Listview turn from transparent to opaque when I click it and how can I change that ? The Listview has a background and transparent elements and they scroll and work perfectly, except when I click it. When I click it the clicked element turns opaque and the background is no longer visible.
How can I change the behaviour so that the opacity does not change when I click elements ?
Edit: Could the focus highlight be responsible for this ? How can I disable that ?
Edit: Android 2.3.4, Tegra 2 device, Bitmaps created with Config.ARGB_8888 parameter.
It was the focus as I suspected. It killed the transparency because the focus color is not transparent.
I removed that effect with:
android:listSelector="#00000000"
Add android:cacheColorHint="#0000" to the list view in the xml