V4/V13 support lib : Fragment work, ViewPager does not? - android

Testing other components in android support library,
On device classLoader can't find ViewPager however it can find other support components FragmentActivity, Fragments etc . ( using V4 as well as V13, gives same result)
What's special with ViewPager ? Does it depends on another support components to work ? (Like Fragment needs FragmentActivity)
NOTE: I think I'm properly exporting support library as dependency, else Fragment would also not have worked.

You should reference it like this:
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<v4support:ViewPager> is not correct. you need the whole package name in the xml.

android.view.ViewPager is present in Android 3.0 and later. The support library version has a different package: android.support.v4.view.ViewPager.

Related

Use android.support.design.widget in Xamarin

I want to try this version of TabLayout in my Xamarin app:
https://developer.android.com/reference/android/support/design/widget/TabLayout
But I can't figure out how to get a reference to it -- i.e. what package to add, and what namespace to use in Xamarin.
I did find a doc about a "tabLayout" here, but it doesn't seem like they are referring to the same one because they say it has been deprecated, which does not appear to apply to the one I want:
https://developer.android.com/reference/android/support/design/widget/TabLayout
Can anyone help?
Nuget Package
Xamarin.Android.Support.Design
Layout usage:
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
~~~
/>
Using example:
using Android.Support.Design.Widget;

I have added Support-v4, but cannot find ViewPager

Today, I was going to make an ViewPager app by Android Studio. I have added support-v4 25.3.1, but I cannot find the ViewPager in the Palette. Can someone tell me how to find it?
Gradle
Palette Search Result
I think the ViewPager purposely not shown in the palette, I can't find it either on my Android Studio.
However, you can add it manually in the XML, for example:
<android.support.v4.view.ViewPager
android:id="#+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_weight="1"/>
After that, try to ctrl/command + click on the ViewPager in XML. If it's opening the ViewPager java class, that means you already have added the support-v4 library(including ViewPager) on your project.

Tools namespace android listitem

I'm trying to use the "tools" namespace feature in Android Studio.
I'm trying to populate the ListView with dummy list items, for design purposes. The link here says the tools:listitem="#android:layout/<filename>" should do.
But for some reason, Android Studio keeps showing Layout android:<filename> does not exist. I'm trying to find a solution for it, so I don't have to run my app again and again with dummy values for testing.
I might be overlooking something very foolish, so forgive me. Here is what I have for now:
<ListView
android:id="#+id/controllerProfiles"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
tools:listitem="#android:layout/profiles_list_item"/>
And I have a file profiles_list_item.xml under res/layout. Any suggestions or alternatives?
you should change the following line :
tools:listitem="#android:layout/profiles_list_item"
to this :
tools:listitem="#layout/profiles_list_item"
with #android you say that you want to use a layout from android resources but your layout is in your own project files.
tools:listitem doesn't work with ListViews in Android Studio 2.2. This is a known bug. I've tested this in Android Studio 2.3 beta 1 and it is fixed here.
You can also move from ListView to RecyclerView as this bug doesn't occur at RecyclerViews.

How can i implement a SlidingDrawer with a ListView inside on Android API Level 10?

I have been messing with android for quite awhile, and i have already built user interfaces using the DrawerLayout from Android Support Library v4.
My college teacher forced us to use API Level 10 for building our apps for this discipline, so that's what im doing.
I am trying to build a SlidingDrawer that has a ListView Inside, but i can't find the right way to do it. The following code leads to two errors
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/details"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<SlidingDrawer
android:id="#+id/slidingDrawerShowMore"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:topOffset="132dip"
android:handle="#+id/handle"
android:content="#+id/handle">
<ImageView
android:id="#id/handle"
android:layout_width="88dip"
android:layout_height="44dip" />
</SlidingDrawer>
Error Messages:
Exception raised during rendering: com.android.layoutlib.bridge.MockView cannot be cast to android.view.ViewGroup
and
Exception raised during rendering: The content attribute is must refer to an existing child.
(This one is raised after i change the content value of the drawer to #+id/content)
Here is the result i am looking forward to achieve.
Navigation Drawer Component
Any ideas of how can i have it solved ?
I have this UI running perfectly on API 17, with a custom ListAdapter on the ListView on the DrawerLayout ( from android.support.v4.widget.DrawerLayout), but it does not work on lower API levels.
You are using NavigationDrawer which uses ActionBar Component in android. This will work on only 3.0 and above. So you need to remove ActionBar code in your app and try you own header code.
Otherwise change the code of actionbar to ActionBarCompat which is a library used to handle actionbar in lower versions and implementation is very easy just follow the url

Android webview dropdown menu does not work on Android 4.x devices

I have a problem with one of my WebView on Android 4.x devices.
Android app has a Tabhost which contains Fragments. One of the fragments contains a webview. The displayed page has a dropdown menu like this:
<select id="mySelect" name="mySelect">
<option value="1">Testname 1</option>
<option value="2">Testname 2</option>
<option value="3">Testname 3</option>
</select>
Now when I open my app with a Galaxy S3 with Android 4.1.1 (or any other Android device I could get my hands on) I can select "Testname 1", then "Testname 2" and so on.
On the Galaxy Nexus (confirmed on different devices running Android 4.1.1, 4.1.2 and 4.2) when I try to select something the UI just blocks. After I switch to another tab and back to the webview tab suddenly the UI finally changes to the previously selected item.
Any idea what is causing this or how I can fix this for the Galaxy Nexus?
Important update:
I could track this down to the Tabhost. When the webview is in the tabhost it does not work, when it is not it works. This might be related to this issue.
You can actually do more with ActionBar than you can with just a TabHost. Including Tabs. link will allow you to implement the ActionBar in older versions minSdk = 4. A majority of the User Experience developers I have worked with think that Tabs are kind of passe although the do provide a familiar UI to users, but who am I to blow against the wind? The ActionBar provides a very Android specific look and clean feel to the UI. link is the documentation on Google's recommended UI patterns from that conference. link is the YouTube video discussing the UI patterns from the conference. Following these recommendations can provide a better review of your application and more sophisticated UI look for it. I am not sure what your needs are but if you are going to do something, might as well do it right? If you need some more help please let me know. I can get you examples on using the ActionBar. ActionBar link can give you some better reasons that I can why it is a good choice for the UI.
Are you implementing your Fragments correctly? link is the documentation on using them. If you are using dynamic fragments instead of fixed fragments implemented in the layout one trick that I found when writing across applications is to call the .clearBackStack(); when I am having funny issues and it seems to fix a lot of problems.
TabHost in ICS? Are you using the compatibility package? Proper design would be to use the ActionBar to implement Tabs if you are working in basically 3.1+.
Try using this custom class in your XML layout instead of the normal TabHost:
package com.example.test;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.TabHost;
public class TabHostFix extends TabHost
{
public TabHostFix(Context context)
{
super(context);
}
public TabHostFix(Context context, AttributeSet attrs)
{
super(context, attrs);
}
#Override
public void onTouchModeChanged(boolean isInTouchMode)
{
//do not call through to base class, do nothing
//this is a fix for tabhost stealing focus from textboxes
}
}
Reference the custom class in your XML layout like this:
<?xml version="1.0" encoding="utf-8"?>
<com.example.test.TabHostFix xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TabWidget
android:id="#android:id/tabs"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_weight="0"/>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" />
<FrameLayout
android:id="#+android:id/realtabcontent"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</com.example.test.TabHostFix>
EDIT:
As an alternative solution, you may be able replace TabHost completely by using the ViewPager from the support library and a custom View Pager indicator that mimics tabs. I've never tried this before, but I have read that there are good free 3rd party view pager indicators here.
After Selecting the select, the List item data might change but we can't see the change. for this we need to explicitly refresh the select component. Hope this might solve the problem.
$("select#HeightUnit option[value='cm']").attr("selected", "selected");
$('select').selectmenu('refresh');
> i think u must add the API version on your activity cause some UI cannot compatible on >android API 8. so check the API SDK like this.
>#TargetApi(Build.VERSION_CODES.GINGERBREAD)
>if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD)
>{
>// condisition
>}

Categories

Resources