Android Tab Layout Tutorial -deprecated things- - android

I continued to do this tutorial. In this tutorial, guy used this code;
public class AndroidTabLayoutActivity extends TabActivity {
in this code TabActivity deprecated. Then I used extends ActivityGroup , it was also deprecated. I searched and I found extends Fragment , but I couldn't apply extends Fragment to tutorials' code. So how can I fix it please ?

Related

Why static nested fragment should be public?

I use Android Studio 3.3.1 and have an Activity which encloses a Fragment:
public class TestActivity extends FragmentActivity {
...
private static class TestFragment extends android.support.v4.app.Fragment {
...
}
}
Android Studio shows this error, although I can run my application:
fragment class should be public
But I am wondering, because TestFragment is supposed to be used only in TestActivity. I did a quick search and only find this answer to a similar question. The answer says:
On orientation change, Activity recreated and framework creates new instance on fragment (and restores previous state). So here to create instance of Fragment, framework asks to provide public constructer.
But the question remains. Why framework asks that when TestActivity has a complete access to TestFragment?

Change the default settings to create new projects

I have two questions here, both related.
When I create a new project with a blank activity in Android studio the project always creates an app with an ActionBarActivity.
public class MainActivity extends ActionBarActivity {
1.How can I change my project defaults to remove this default and just create a project as:
public class MainActivity
OR
to update it so its is not creating an app with deprecated code. Please see image.
Unfortunately there is no way to reconfigure the content of main activity created by default. Possibly the Google engineers will fix it some time in the future.
What you can do here to save some time is move the caret to the ActionBarActivity while being in the MainActivity.java file and hit Alt+Enter. The quick fix "Replace with AppCompatActiivty" will pop up and all you'll need to do is hit Enter to apply it. It's easier than replacing ActionBarActivity with AppCompactActivity by typing.
For 1. change to public class MainActivity extends Activity
For 2. change to public class MainActivity extends AppCompactActivity
EDIT: Creating project without activity.

SlidingMenu Library with ActionBarSherlock

In the documentar from SlidingMenu is written down:
Go into the SlidingActivities that you plan on using make them extend Sherlock__Activity instead of __Activity.
The setup should be ok, I followed the guide, but if I try to extend my Activity with for example: SlidingSherlockFragmentActivity or SherlockSlidingFragmentActivity doesn't work.
If I extend my Activity with SherlockFragmentActivity I can't get the SlidingMenu with getSlidingMenu() or call setBehindContentView.
Nevermind, go into the SlidingMenu library and extend the Activity by SherlockFragmentActivity instead of FragmentActivity
Go to activities of library SlidingMenu and extends all activities to SherlockActivities corresponding, after go to your app and extends all activities to SlidingActivity corresponding.
Example: SlidingMenu:
SlidingActivity extends SherlockActivity
SlidingMapActivity extends SherlockMapActivity
Example: MyClass
MyClass extends SlidingActivity
MyClass extends SlidingMapActivity

Extend Activity with MapActivity and ActivityGroup

I'm new in Android.
How am I be able to extend an Activity with both MapActivity and ActivityGroup??
Because I need to display both a Map and a customized Tab on an Activty.
public class MainActivity extends ActivityGroup implements MapActivity
Somehow I'm not allowed to do that.
To display a tab use Fragment, coz ActivityGroup is Depreciated.

MapActivity in a fragment

I have a FragmentActivity:
public class parking extends FragmentActivity { }
It has 3 tabs, the second and third are lists, solved.
public class tab2 extends Fragment{ }
But the first one is a map, so, I can't extend Fragment and a MapActivity.
How can I solve it?
There is no support for MapFragment, Android team says is working on it since Android 3.0. Here more information about the issue http://code.google.com/p/android/issues/detail?id=15347&utm_source=buffer&buffer_share=acc72
But what you can do is create a Fragment that returns a MapActivity. Here is a code example. Thanks to inazaruk: https://github.com/inazaruk/examples/tree/master/MapFragmentExample
How it works:
MainFragmentActivity is the activity that extends FragmentActivity
and hosts two MapFragments.
MyMapActivity extends MapActivity and
has MapView.
LocalActivityManagerFragment hosts
LocalActivityManager.
MyMapFragment extends LocalActivityManagerFragment and with help of TabHost creates
internal instance of MyMapActivity.
if you have any doubt please let me know
Google released the Map API Version 2. This finally allows us to use a MapFragment and a SupportMapFragment. This allows adding Maps to ViewPagers and to Activities that do not extend MapActivity.

Categories

Resources