PopupMenu in older android API - android

can I use PopupMenu in older API without using support library v7 ?
I am already using support library v4, but it's not enough for this
and what is the alternative, if I don't use it ?

PopupMenu is only available in API 11 or higher. As far as I can tell from the documentation it is not included in any support library and thus cannot be used on a lower api version. You should probably use an alternative like a Dialog or ContextMenu in those situations. It's not the same thing but kind of close.

You must import support v7 in your application same as follow:
Adding libraries with resources
and in your project import android.support.v7.widget.PopupMenu and then compile your code with that your popup menu is compatible for android 2.2 and above.

Related

eclipse android textinputlayout cannot instantiate the class on designer, inflater error on runtime

how to properly use the textinputlayout? what has been tried are as follows:
import the appcompat project import as library, import the support design jar
import the appcomtap project import as library, import the support design project import as library.
both produced the error No 'id' attribute supplied <public>, and no previous id defined in this file. this files are from support design -> res-public -> public_attr, public_string and public_styles.
if I did not included them, it says like missing backgroundTint.
the manifest file uses sdk min 11, target version is 22. the appcompat and support design is also 22 (tried 23 for all of them non worked).
also updated the support library to latest
what is the correct steps?
found the answer, just follow the steps provided by the answer marked as correct. steps to properly use android design support library
basically just import the app compat v7 targeting the latest api
then create an android project for design support and place all files of the design support library and then add the app compat v7 library to the newly created android project (design support)
you can then use this project marked as library to any project that needs this design support library (just make sure the app theme uses the Theme.AppCompat.Light.DarkActionBar at least to make it work)

Android support library v7

I am making an android app that contains action bar and fragment which are not supported for API level 8!
So I just tried to import support library V7 to fix this problem!
But when I try to do it , it doesn't find support library for V7 , there is support.v4 but not v7.
what should I do to fix it?
Should I download anything for my android SDK?
Download Android Support Library in Your SDK manager under Extras. Then Import appcompat from following folder in your sdk.
Android-SDK\extras\android\support\v7\appcompat
The first step is to download the library through the SDK manager.
Support library v7 is a library project, so needs to be added as a new project to your workspace.
Note: You can't just drop the .jar in because it has additional XML resources.
There's some pretty thorough instructions on how to add it located here.

How to create a ActionBar in Android 2.2 version?

I'm new in Android programming. I just wanna how to create a ActionBar for android 2.2 version.
You can use ActionBarSherlock. It's an open source library that emulates the exact features and design of the ActionBar.
Please see: http://actionbarsherlock.com
Google uses this as well in a number of applications.
yes ActionBarSherlock is best option,
Please See https://github.com/JakeWharton/ActionBarSherlock
Use AppCompat library from com.android.support.
Google has released com.android.support to support things like this on older devices
Add the dependecy in build.gradle (it's NOT in the root directory) inside dependencies{...}
dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'
}
And change your theme to Theme.AppCompat or Theme.AppCompat.* (The wildcard represents more styles inside Theme.AppCompat

Is it Possible? app developed in 2.x device with compatibility lib V4 to use native library if device is android 3.x or greater device?

Before posting my question. i looked this one stack overflow.and wann know, is it really impossible? i have app developed in android 2.2 with the use of compatibility library v4. which is also compatible with android 3.0 device. and i want my app to use android compatibility library v4 if device is android 2.x and native library if device is android 3.x. any suggestion??
thanks in advance
I haven't tried what I'm recommending, but it could work:
Set your build target to Honeycomb
Use an if-else statement and Build info to determine which version of Android you're on
If you're below 3.0, use the compatibility library in your code
If you're on 3.0 or above, use the native library.
For this to work, you'll need to use fully qualified names in your code, instead of having import statements on the top. So for Fragments on 3.0 and above, you'd use:
android.app.Fragment fragment;
instead of:
Fragment fragment;
and an import statement on top. And finally for pre 3.0, you'd need statements like:
android.support.v4.app.Fragment fragment;
You need to use these names as you cannot import both version and use only one.

Android - Fragment API for API level < 11

I have came across a problem for dynamic forms in my app, which is suited for Android 2.1 and above. I know there is new Fragment API since API level 11 (Android 3.0 Honeycomb), but also I have read an article - http://android-developers.blogspot.com/2011/03/fragments-for-all.html stating Fragment Api is available also for API level lower then 11 in, so called, Compatiblity package. I have installed it via SDK, but I am not able to use is in my App, e.g. I cannot import android.app.FragmentManager, application doesn't know it.
Do you know, how to solve it? Is Fragment API truely available for older API levels? If so, how to make them going? Or is there any other solution like Fragments API? I will need for dynamic generated forms if possible
Thanks
Hmyzak
Android Studio:
Add a dependency for support compatibility package v4:
dependencies {
...
compile 'com.android.support:support-v4:21.0.+'
...
}
and then use import android.support.v4.app.Fragment; instead of import android.app.Fragment; in imports.
You need to add the package to the build path.
Use ActionBarSherlock. It comes with a lot of working examples.

Categories

Resources