XML Version Encoding XMLNS: Package :name : Android
XML Version Encoding XMLNS: Package :name : Android
xml
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"
/>
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="Heatloss Calculator"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="GEO-HLC"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
</application>
</manifest>
MainActivity. Java
package geothermal.tab_heatloss02;
import android.support.design.widget.TabLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
/**
* The {@link android.support.v4.view.PagerAdapter} that will provide
* fragments for each of the sections. We use a
* {@link FragmentPagerAdapter} derivative, which will keep every
* loaded fragment in memory. If this becomes too memory intensive, it
* may be best to switch to a
* {@link android.support.v4.app.FragmentStatePagerAdapter}.
*/
private SectionsPagerAdapter mSectionsPagerAdapter;
/**
* The {@link ViewPager} that will host the section contents.
*/
private ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
//deleted PlaceholderFragment class from here
/**
* A {@link FragmentPagerAdapter} that returns a fragment corresponding
to
* one of the sections/tabs/pages.
*/
public class SectionsPagerAdapter extends FragmentPagerAdapter {
@Override
public Fragment getItem(int position) {
//Returning the current tab
switch (position) {
case 0:
Tab1spring tab1 = new Tab1spring();
return tab1;
case 1:
Tab2steamingground tab2 = new Tab2steamingground();
return tab2;
case 2:
Tab3fumarole tab3 = new Tab3fumarole();
return tab3;
case 3:
Tab4hotpool tab4 = new Tab4hotpool();
return tab4;
case 4:
Tab5tambahan tab5 = new Tab5tambahan();
return tab5;
case 5:
Tab6info tab6 = new Tab6info();
return tab6;
default:
return null;
}
}
@Override
public int getCount() {
// Show 6 total pages.
return 6;
}
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return "page 1";
case 1:
return "page 2";
case 2:
return "page 3";
case 3:
return "page 4";
case 4:
return "page 5";
case 5:
return "help";
}
return null;
}
}
}