android-compatibility

What is LinearLayoutCompat in appCompat v7?

江枫思渺然 提交于 2019-12-20 10:26:15
问题 In the support library appCompat v7 of the Android platform, there is a android.support.v7.widget.LinearLayoutCompat class. Does someone know why this class exist? The original LinearLayout class exist since API level 1 so I don't understand why there is a compat version. 回答1: The class LinearLayout exists since API level 1, but some APIs were added after that, for example, setShowDividers introduced on API level 11. So in this case setShowDividers (and it's parameters) should be invoked

“You need to use a Theme.AppCompat theme (or descendant) with this activity” when using AppCompat theme

▼魔方 西西 提交于 2019-12-20 05:48:10
问题 I have a very strange problem with my app. After updating to the newest versions of Support libraries I get this error: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.app/com.example.app.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. This is where the exception is thrown: public class MainActivity extends AppCompatActivity { … @Override protected void onCreate(Bundle savedInstanceState

Android solving compatibility with SDK_INT hack; is this ok?

只愿长相守 提交于 2019-12-19 11:57:10
问题 Running the following (note: target > 3.0) ActionBar actionBar = getActionBar(); on Android with version < 3.0 (SDK 11) results in a NoSuchMethodError . There are several ways to get around this, including reflection and class lazy loading. However, the following seems to work across all the devices I've tested (2.3.6, 3.0, 3.1, 4.0): boolean hasActionBar = android.os.Build.VERSION.SDK_INT >= 11; if (hasActionBar) { ActionBar actionBar = getActionBar(); } else { // create custom actionbar }

AndroidHttpClient and HttpGet API deprecated in Android 6.0 Marshmallow (API 23)

可紊 提交于 2019-12-19 03:56:45
问题 Today I have updated android SDK API 23. As soon as I have changed my project to target Android SDK API 23, I started to get an error regarding Apache's client and AndroidHttpClient API in eclipse. Apache library API can no longer be found in API 23, nonetheless to continues to be working fine with API 22 and below. Can someone kindly suggest what the problem is behind these errors? One more error in project Thanks. 回答1: The entire Apache API was removed from SDK 23 since from SDK 22 it was

How to clean back stack on Android API 10 (Android 2.3.3)

拥有回忆 提交于 2019-12-18 08:48:33
问题 I would like to know how can I clean all previous activities of the stack (except the new one), but I want that in Android API 10 (Android 2.3.3). Guided with this answer, I know it is not directly possible because the flag dedicated to do that exists since API 11. But I would like to know if this is possible maybe with some compatibility or if someone has any solution. Thanks in advance. 回答1: On way to do this is to always start your activities using startActivityForResult() . In the case

Android Support Package / Compatibility Library - use v4 or v13?

Deadly 提交于 2019-12-17 18:25:44
问题 I've just read this description of the Android Support Package / Compatibility Library... http://developer.android.com/sdk/compatibility-library.html ... and it's left me a little confused! It says that the v13 library is a superset of v4 but I thought it was the other way around? Getting practical: If I want to use the compatibility library such that my app builds and works fine for phones running Android 2.2 (API 8) through to 4.0 (API 14) and beyond, will v4 suffice for me? 回答1: To target

reusing fragments in a fragmentpageradapter

杀马特。学长 韩版系。学妹 提交于 2019-12-17 05:36:11
问题 I have a viewpager that pages through fragments. My FragmentPagerAdapter subclass creates a new fragment in the getItem method which seems wasteful. Is there a FragmentPagerAdapter equivalent to the convertView in the listAdapter that will enable me to reuse fragments that have already been created? My code is below. public class ProfilePagerAdapter extends FragmentPagerAdapter { ArrayList<Profile> mProfiles = new ArrayList<Profile>(); public ProfilePagerAdapter(FragmentManager fm) { super(fm

Error inflating class switch, ActionBarSherlock (InflateException)

自古美人都是妖i 提交于 2019-12-11 08:22:47
问题 I'm running into a pain of an error. I have a SherlockFragmentActivity, and at least two SherlockFragments. Both use onCreateView to inflate an xml file. LoginFragment, however, has a switch widget: econ fragment does not. If I add a switch widget into econfragment.xml, that causes a crash of the same type (while loginfragment is commented out of implementation). If I remove the switch widget from loginfragment, a similar error shows up for RadioGroup - but econfragment already has a radio

FragmentActivity with a Fragment Containing a MapView

狂风中的少年 提交于 2019-12-11 03:33:31
问题 I know there are a few questions like this but what I'm looking for is slightly different the way I see it. THE PROBLEM I have one Activity and I am only ever going to have one Activity . I do however have multiple Fragments ; one of which contains a MapView . I have successfully got this working in API level 3.0 and greater. However, the problems start when I want to go lower than this using the compatibility library as I then need to make my Activity extend FragmentActivity to get Fragments

How to use Android's AppCompat theming application-wide?

人走茶凉 提交于 2019-12-11 02:19:20
问题 IDE : Android Studio 1.1.0 ENV : Debugging on usb-connected phone using Android API v10. I'm trying to use AppCompat to support Android API v8 and up. Compiles fine but crashes when the activity is drawn, saying: lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. ...however, in AndroidManifest.xml I have: <application android:name=".objects.PikCMS" android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app