I'm using the framework from here - cardsui
How can I add a share button to the top of the cards. I've implemented it in the xml with an on click method, but the app crashes when I press it and says that the method doesn't exist (yes, I added the method to the main java file. also to the card.java file but still the app crashes...).
Has anyone used this framework and encountered this?
Thank you
You might want to check this addon for CardsUI: https://github.com/Androguide/cardsui-for-android
As developer wrote:
The Google Play cards come with more customization parameters than the other regular cards, those parameters include :
Title (String)
Description (String)
Stripe color (String)
Title Color (String)
Enable an overflow menu on the card. It's not finished yet, I still
need to implement the popup menu when clicked (Boolean)
Enable touch feedback on click or disable it (Boolean)
If you replace the overflow menu with buttons, at least you get a boolean and then handle the actions accordingly.
I wonder if you should just use a simple ListView, and apply a custom background to your adapter to give it the card UI. Then you are just using a simple ListView (with no additional framework - ie. just standard Android UI).
I describe how I did this in the following SO answer: How to create Google + cards UI in a list view?
I would guess that you ARE able to add an onClickListener to the component of your card, as this is pretty standard Android (chances are the Framework you are using DOES support this). Don't know your specific issue unless you post more code.
Related
I'm writing a POC Android TV app for my company based on our existing mobile OTT product and backend.
I'm modifying the PageAndListRowFragment example from Google's Leanback Showcase code.
When a header option is selected (with OK or right arrow) I want the RowsFragment side to popup an AlertDialog to let me filter the content displayed ('all', 'latest', etc).
My problem is that I have the AlertDialog in the RowsFragment onCreate So, It displays as soon as the HeadersFragment is highlighted. This stops the user from scrolling down the header smoothly and is confusing because you still have to select the header item after the dialog.
Most advice on the web seems to point to overriding the OnItemViewClickedListener function on the HeadersFragment but I can't find a way to do this. (The leanback showcase uses the deprecated BrowseFragement code, Not BrowseSupportFragment and if I try to change up I get into FragmentFactory errors I'm not experienced enough to resolve).
I've also tried implementing isShowingHeaders() in the RowsFragment.
I've tried to find a stage of the fragment lifecycle in either HeadersFragment or RowsFragment that will let me popup the dialog when the RowsFragment is full screen without success.
I'm already using the PageRowFragmentFactory code in the leanback showcase code to send an EventBus message containing the header option chosen and was hoping to send a similar message to trigger the dialog.
I've tried setting up a setOnHeaderViewSelectedListener on the BrowseFragment but can't seem to successfully get it invoked.
I'm new to Android programming so apologies for my ignorance, but I'm determined to make this work somehow.
Any suggestions on the approach would be very much appreciated, thanks.
I want to achieve something like this -- text selection plus custom actions ..
http://www.youtube.com/watch?feature=player_embedded&v=iwmG43D0vD4
I have done sufficient research on this topic and concluded that webview text selection and overriding it functionality is not possible ..
Seems that webview's functionality is very limited atleast in the case of text manipulation.
I had decent success by accessing webview's private nativeGetSelection method ( i was able to get selected text ).. but still i was unable to suppress the default dialog box .. and using private methods dosen't seem to be a safe action tooo ..
I was about to scrap my thought of doing that project .. then i came to see that default web browser provides good text selection capability and further provides custom quick action to manipulate the text .. I am really confused at this point ....
can anyone .. with all their expertise ... point out how to achieve that behavior .. ?
what view does google docs app use to achieve that behavior .. ?
I got something similar working in 2.2 - 4.0.3. I used a javascript interface and passed all touches to it. Of course to do that you'll need enough control over the web content to include the javascript file. I have this solution in an app in production and I've put an example project on github. The github project includes the necessary js in the assets folder as well as a test page and web view that loads the test page and implements all necessary methods to handle the selection. The link to the github project is https://github.com/btate/BTAndroidWebViewSelection. Have at it.
I want to be able to do what is on the picture, provided by this link, under the "Allow cutting through hierarchies" section. I thought that I could do that using a spinner, but from the android documentation I realized that a spinner can show one child at a time and lets the user pick among them. In my case, (and from the example I provided), you have some other text displayed, and then you can choose from some other options provided in sth that looks like a popup, list that contains the things that i want to choose from. I don't know how this is implemented, but it's used in the google music app for android 4.0. If someone has an idea, have implemented sth like this, please give me some advice.
It is not a spinner. Its just a view (in the Mail app a relative layout) See here
On click this View opens a popupmenu.
Therefore it is looking like a spinner but you can add you custom behaviour.
I would like to show a tooltip, i.e. additional non-essential information about a View when the user long-clicks on it.
The two options I see in front of me are using an OnLongClickListener to construct a custom tooltip in front of the clicked View; or abusing an OnCreateContextMenuListener to create a context menu that isn't.
Neither seems like the best way to go about things, and I'm not sure whether either will work. I've scoured the web and haven't found any hints. Any alternatives, or should I be wet-fish-slapped for trying to do this? Thanks!
Android Oreo has introduced the android:tooltipText attribute in order to display a simple Toast-like tooltip when user long-presses on a View:
<Button
// ...
android:tooltipText="#string/share_button_tooltip"/>
Although it has been introduced in API 26, you can still use it through the Support Library's TooltipCompat helper class:
TooltipCompat.setTooltipText(shareButton, getString(R.string.share_button_tooltip))
My suggestion is to set android:contentDescription and then use it as the tooltip text to kill 2 stones with 1 bird:
<Button
// ...
android:contentDescription="#string/share_button_tooltip"/>
TooltipCompat.setTooltipText(shareButton, shareButton.getContentDescription())
Is there a standard way to add a footer to a context menu, in which I can add a checkbox to make the selected option the default one?
Similar to the context menu that comes up when choosing the default home screen for example.
From the Api docs for ContextMenu I see that you can set a header view, but not a footer view. Also the setCheckable / setGroupCheckable methods don't seem to help much here.
Does this need to be done via a custom (alert) dialog? I would be wondering if nobody has yet developed such a component yet in case it's not possible through the standard SDK api. Any standalone open source component out there (beside the Android source itself)?
The best I've come up with is using an AlertDialog
alert.getListView().addFooterView(...); and overriding it's onItemSelected method.