How to remove android v7 -app compat support - java

I am facing some problem in android suppport v7 app compat. is giving error that some jar missing. I want to make a simple hello world app with android support v4 or something, but how to remove android support v7?

It's a bit of a chore to remove it. It's easiest to just create a new project, unchecking "Create Activity" in the wizard and then add a new class to src.
But if you really, really want to remove the v7 stuff from an existing project, here's one way to remove it, the action bar, and the fragments stuff:
Delete the android.libary.reference line from project.properties, ignoring the warning at the top.
Change the type of MainActivity from ActionBarActivity to just Activity.
Delete the v7 and v4.Fragment imports.
Delete the whole "if (savedInstanceState)" statement from MainActivity.
Delete the PlaceholderFragment class from MainActivity.
Replace the contents of activty_main.xml file with the contents of fragment_main.mxl or your own layout.
If you didn't use your own layout, remove the tools:context attribute/value from activity_main.xml.
Edit each of the 3 styles.xml files (under values*) and change the parent of style AppBaseTheme to "android:Theme.Light" (or your choice).
Edit menu/main.mxl and remove the app:showAsAction attribute/value.
Organize imports and clean your project.
Just to be clear: this isn't something you really want to do for a real app, but more something that you might want to do if you're just creating a demo or proof of concept.
Edit:
Going forward, you can add an additional template that creates an Activity without appcompat_v7. You can get one by CommonsWare here. There's a nice write about it here.

For your information this happened because you upgraded your ADT to the most recent version (22 I think).

Related

Cloning an android activity dynamically?

I'm creating an application with a rather dynamic UI that allows users to add/change the positions of its views and layouts dynamically. If the user decides that current UI design satisfies him he would be able to save all views(buttons/labels/switches/etc.) of the activity into a list of "saved" activities. Is there a possible way to clone an activity or at least save the positions of all views and layouts? I saw that views have functions .getX() and .getY() but as far as I understood it is only within a layout.
Update
I found a solution that works. I created a simple Sqlite Database the stored the XY locations/names/text/id of all my views in to a table dynamically and then displayed them in a list of 'saved' configurations. The hard part is creating dynamically again all the views after you get the DB. If there is a request, I can also put some code up.
I'd create a base-activity, that has the functionality that both of your Activities need. This functionality would have to be slightly abstracted so that both activites could use this functionality by extending this BaseActivity and use it for their individual purposes.
If you post some code (the part of code both of your activities should have), I could update my answer to show you how that would look like in your case.
Further,
Step #1: Open the old project in Android Studio.
Step #2: Open the new project in Android Studio, choosing to open it in a new window (rather than the window you have from Step #1).
Step #3: Drag and drop the Java class files from the old project into the new project.
Step #4: Drag and drop the resources used by those Java classes from the old project into the new project.
Step #5: Find the elements from the manifest of the old project and copy those into the same basic location in the manifest of the new project.

How to create a navigation that open from bottom of screen?

I want to create some thing like drawer menu that open from bottom of screen.
some thing like blow image. Also I want to know is that any special name?
You can use BottomSheet library. It works on Android 2.1+
https://github.com/soarcn/BottomSheet
It's called a SlidingDrawer. It was on the SDK but got deprecated a while back.
That said, this thrid-party library should do the job just as good. I've used it in multiple projects.

Android studio appcombat actionbar setup

I've managed somehow to add the action bar when i extend ActionBarAtcitivy, but what if i want to call for example: ListActivity and still have the action bar?
I have a strange feeling that i missed something when i added the appcombat library, because in the preview design window actionbar is never displayed, though if i launch the app, the action bar is there(But only if i extended the ActionBarActivity).
How i installed the actionbar:
I downloaded the library and the repository.
I added the compile com.android.support:appcompat-v7:21.0.3 in build.gradle.
I have the android:minSdkVersion="8" android:targetSdkVersion="21" declared in my build.gradle script.
Ive done these parts, as told in the android studio documentation.
Another interesting thing, when i'm trying to import the android.support.v7.app.ActionBar it just disappears immediately. whatsthat about?
You need to stick with ActionBarActivity if you want to use this library. For your particular case, instead of having a ListActivity, you should:
have an activity extending ActionBarActivity;
load a ListFragment into it, possibly from the support libraries as well (android.support.v4.app.ListFragment).
Regarding your second question, the "design" view will not show your toolbar if you load that at runtime. It just reads your layout XML file without running any code, according to the theme you have set. It should not be intended as a real, reliable preview of what your activity will look like. For that you need an emulator running the OS, or a real phone.

What is fragment_main?

I've recently setup eclipse and the android SDK on a new computer but I fear something has gone wrong when setting it up.
When I create a new android project with a blank activity two files I've never seen before appear:
fragment_main.xml
and
appcompat_v7_2
What are they and do I need to worry about them?
appcompat-v7 :
As stated in Android's Support Library Overview, it is considered good practice to include the support library by default because of the large diversity of devices and the fragmentation that exists between the different versions of Android (and thus, of the provided APIs)
Reference : Why does Eclipse automatically add appcompat v7 library support whenever I create a new project?
Fragment_main :
fragment_main.xml is the Layout for the fragment.
Refer this : Building a Dynamic UI with Fragments
hope this helps
The first, let read code in MainActivity!
You can see fragment_main is layout of one fragment in it.
when application running, fragment will be added to layout and show this layout.
Let read more about here for understanding about fragment. It is very important if you want to make android app.

XML files and the ActionBar

I am very new to android programming, migrating over from iOS and I am having a hard time.
So, I have set up a new application in Eclipse IDE with a fixed tab and swipe navigation. So it appears to have created a ActionBar. However, I need to change the content of each page rather than it just telling me which tab I clicked.
I have been searching for this for about, 30-45 mins now, and I cannot find anything which makes any sense!
How can I attach a new XML file to a view?
I think the code you are looking for is:
setContentView(R.layout.your_xml_file)
Make sure your xml file is in your res/layout folder in your project
As for your button listener, check this answer.

Categories