Webview URL items not Visble - java

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,

Related

I can't Connect navigation drawer items with there related activities and fregmant

I have made a navigation drawer in my app , but I have a problem that I can't open any activity related to any menu item in navigation drawer .
for example in this code I am trying to only display a toast message ,also there is no response when I click on the item from the menu.
I assume you are using menu items and I would suggest giving the same id for the navigation destination and its corresponding item.
if items id is nav_home then destionation id should also be nav_home in navigation.xml
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
appBarConfiguration = AppBarConfiguration(setOf(
R.id.nav_home, {*other navigations*}), binding.drawerLayout)
setupActionBarWithNavController(navController, appBarConfiguration)
binding.navView.setupWithNavController(navController)
when you set it like this it will automatically connect the destination to items and u dont have to set the onclick manually

Unable to navigate from app bar after setting focusable attribute

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"

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.

Espresso RecyclerView inside ViewPager

I am new to Android Espresso library. Trying to test click on RecyclerView item inside the ViewPager. I've searched the Internet but found nothing about ViewPager. So my question is: how to access RecyclerView inside a ViewPager using Espresso to perform click?
Let's suppose you want to tap on buttonClick, which is the id of a button inside your RecyclerView.
I use this code:
onView(allOf(withId(R.id.buttonToClick), isCompletelyDisplayed()))
.perform(click());
This gets the view with this id which is currently displayed and performs a click on it.
Hope this helps.
P.S.: Also, on espresso-contrib there are RecyclerViewActions that maybe you can use: actionOnHolderItem, actionOnItem and actionOnItemAtPosition. You can do something like:
onView(withId(R.id.recyclerView))
.perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));

Disappear SmartTabLayout pageViewer content

I'm trying to use SmartTabLayout from here https://github.com/ogaclejapan/SmartTabLayout, and i have a drawer. When i'm clicking at item on drawer, i replace my fragment, to fragment with smarttablayout. For first time it's ok, smarttablayout have tabs with content, but when i click in drawer on the same item, content of tabs just disappear, and to show them back i have to scroll to the end, and scroll back, to show them. I don't have idea why.
Notes: If using fragment inside a ViewPager, Must be use Fragment#getChildFragmentManager().
https://github.com/ogaclejapan/SmartTabLayout#pageradapter-for-fragment-based-page
FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
getChildFragmentManager(), FragmentPagerItems.with(this.getA())
.add(R.string.item_pager_title_products, ProductListFragment.class)
.add(R.string.item_pager_title_shops, ShopListFragment.class)
.create());
FYI: Had same problem because I didn't read the manual... Original answer found here https://stackoverflow.com/a/25525714/1257369

Categories

Resources