Unable to navigate from app bar after setting focusable attribute - java

I am creating a very simple WebView app with a few useful links and I want the initial focus to be on the app bar with easy access to the menu. This works if I add focusable attributes to the layout in main.xml
android:focusable="true"
android:focusableInTouchMode="true"
However I'm unable to navigate away from the app bar to the WebView content below unless I add requestFocus to the menu actions:
case R.id.url:
webView.loadUrl("https://example.com");
webView.requestFocus();
Then I can navigate down to the WebView content below, but as soon as I return to the app bar navigation is lost again. How can I freely navigate away from the app bar?

So I added the following code to main.xml and it solves my issue
android:nextFocusDown="#+id/webview"

Related

Android: Linking to URL in Navigation Drawer

I am using the Navigation Components library for my Navigation Drawer. I want one item in said drawer to link to an external Website. The offical documentation doesn't say anything about external links. How do I implement that?
I could create a temporary fragment and navigate to that first but this solution is not very elegant in my opinion.
The line
NavigationUI.setupWithNavController(navigationView, navController);
Calls setNavigationItemSelectedListener internally to connect destinations to menu items - this is how a new destination is launched when you click a menu item. Navigation supports <activity> destinations, allowing you to start an activity when clicking on a menu item. You'd add an activity destination to your graph that uses the same id as your menu item:
<activity
android:id="#+id/nav_login_activity"
app:action="android.intent.action.VIEW"
app:data="https://www.your_url_here.com"/>
Then the default setupWithNavController will call startActivity for you.

Webview URL items not Visble

I have a android studio Project with a Webview and a Nav Bar and with the Nav bar I can change between WebViews.
My Problem is that when I but something in my ShoppingCard and switch with the Nav bar to my Shopping Card the Items in there are not Visble how can I solve, this? the ShoppingCard URL ends with .php if this helps
Best Regards T.S
just created a tiny app with two tabs which change two webviews. TAB 1 webview show cart items, other one (TAB 2) show product listing , from product listing i can add product and cart page auto reloaded/refreshed using AndroidCartApp (a JavascriptInterface ) class, and i can see added items in carts, there is no such issue, in this app, other than tabs all is under webviews/htmlapp , maybe you are adding items to cart in other way,

Disabling Contextual Action Bar Crosswalk-Cordova

Contextual Action Bar (CAB) won't disable using Crosswalk as a plugin in Cordova.
Tried everything, starting with the CSS, all the way through HTML & JavaScript, and even MainActivity.java & XWalkCordovaView.java.
I must disable the Contextual Action Bar. It cannot show up. It's messing my entire app. It needs to be gone, completely. Or at least, I settle with not seeing it in my app.
Here are some pictures:
As you see, we need to select text and show that toolbar (the black one, and disable the blue contextbar, prevent it from showing at all). It's not allowing us to use our toolbar. I mean, with Contextual Action Bar, NO WYSIWYG will work nicely.
I even have problems with the arrow select, which I'd like to disable as well, or at least change the color, or not mess up the sidenav.
So, what I tried:
MainActivity.java
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set by <content src="index.html" /> in config.xml
loadUrl(launchUrl);
// disable the context menu and all long clicks
super.appView.getView().setOnLongClickListener(new View.OnLongClickListener() {
public boolean onLongClick(View v)
{ return true; }
});
super.appView.getView().setLongClickable(false);
}
}
From here:
How to disable long-click which opens the Android top menu bar with copy/paste/etc. buttons in Cordova Crosswalk apps?
Pull Request: https://github.com/crosswalk-project/crosswalk/pull/3193
Now, please, I need to disable the Contextual Action Bar when I select some text. Thank you so much in advance. I've searched the whole web and nothing seems to work.
I've filled an issue on Crosswalk Project's Issues:
https://crosswalk-project.org/jira/browse/XWALK-7206

Android tab bar with different fragments and different action bar icons

Problem Description and Question
I'm using tab activity with action bar. In the HOME tab I have GridView which contains some items, like it is shown in the image below (Hot Lines, Taxi, Restaurants etc)
Wen user click on the items in the grid view I want my application to take following actions:
Change icon of application to grid view item image on which I pressed.
Change the test near the icon
Add standard back button near icon, which will go back to grid view screen.
Change the tab fragment to the one which I specify.
Like it is shown in the image below:
As I never deal with this kind of problems can you please give me example or share some link with me of how I can do this? and can I do this at all?
This might help:
Android studio - is possible to add tabs pointing to fragments from designer?
It is not exactly what you want, but a good start. If you are willing to put a bit of work in it, you should be able to get what you want. If you have a basic Frame to work with and more specific problems with this matter I will gladly help you out ^^
John
The first link you can check is THIS.
And you should read more about ActionBar.
The last thing is it's better if you google it first and try to write a code and when you got stuck somewhere share your code with us and ask for help.
You have to use actionbarsherlock library for it.
use android.support.v4.app.FragmentTabHost and TabWidget in the xml as shown below :
<android.support.v4.app.FragmentTabHost
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
style="#style/yourstyle"/>
<FrameLayout
android:id="#+id/realtabcontent"
style="#style/realtabFrameContentStyle" />
<TabWidget
android:id="#android:id/tabs"
style="#style/yourtabstyle" />
</android.support.v4.app.FragmentTabHost>
Use SherlockFragmentActivity for showing the tabs.
In the activities code use following code (preferably in a function) to set the ctionbar icon and text :
activity.getSupportActionBar().setDisplayShowCustomEnabled(true);
activity.getSupportActionBar().setCustomView(R.layout.your_action_barlayout);
((TextView) (activity.getSupportActionBar().getCustomView().findViewById(R.id.action_bar_title))).setText("your title");
ImageView homeButton = ((ImageView) (activity.getSupportActionBar().getCustomView().findViewById(R.id.your_icon)));
homeButton.setVisibility(View.VISIBLE);
homeButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(context, YourHOmeActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
activity.startActivity(intent);
activity.finish();
}
});
ActionBar mActionBar = activity.getSupportActionBar();
mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
mActionBar.show();
then call this function with your icon and your text in your fragments onResume() method.

Open TextView links at another activity - custom ClickableSpan

I have a TextView with links and other text. I need to links to be clickable & I need to capture the click and open the link in a webview in my activity. I followed this this answer. My code looks like this:
actitivity_main.xml
<TextView android:id="#+id/textlinktest"
android:layout_width="wrap_content"
android:layout_height="50dp"/>
And this is the way I invoke it:
textLinkTest.setText(Html.fromHtml("Something else google"));
textLinkTest.setText(RichTextUtils.replaceAll(
(Spanned) textLinkTest.getText(),
URLSpan.class,
new URLSpanConverter()));
The links show up fine, but they are not clickable! The onclick in my customeclickablespan never gets called. I tried toggling android:linksClickable & also tried different values for android:autoLink. But the links remain unclickable. Any thoughts?
Add
textLinkTest.setMovementMethod(LinkMovementMethod.getInstance());
before
textLinkTest.setText(RichTextUtils.replaceAll((Spanned) textLinkTest.getText(), URLSpan.class, new URLSpanConverter()));

Categories

Resources