Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ini bagian activitynya
- package com.catcode.sipintar;
- import android.content.Intent;
- import android.os.Bundle;
- import android.support.design.widget.NavigationView;
- import android.support.v4.app.FragmentTransaction;
- import android.support.v4.view.GravityCompat;
- import android.support.v4.widget.DrawerLayout;
- import android.support.v7.app.ActionBarDrawerToggle;
- import android.support.v7.app.AppCompatActivity;
- import android.support.v7.widget.Toolbar;
- import android.view.Menu;
- import android.view.MenuItem;
- import android.view.View;
- import android.widget.Button;
- import android.widget.TabHost;
- public class MainActivity extends AppCompatActivity
- implements NavigationView.OnNavigationItemSelectedListener {
- private Toolbar toolbar;
- private TabHost tabHost;
- private Button btn_tindak;
- private TabHost host;
- private TabHost.TabSpec spec;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
- host = (TabHost)findViewById(R.id.tabHost);
- host.setup();
- //Tab 1
- host.addTab(host.newTabSpec("Hari ini").setIndicator("Hari ini").setContent(R.id.tab1));
- //Tab 2
- host.addTab(host.newTabSpec("Osis").setIndicator("Osis").setContent(R.id.tab2));
- // spec = host.newTabSpec("Osis");
- // spec.setContent(R.id.tab2);
- // spec.setIndicator("Osis");
- // host.addTab(spec);
- DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
- ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
- this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
- drawer.setDrawerListener(toggle);
- toggle.syncState();
- NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
- navigationView.setNavigationItemSelectedListener(this);
- btn_tindak = (Button) findViewById(R.id.btn_tindakan);
- btn_tindak.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- // Intent intent = new Intent(getApplicationContext(), QRActivity.class);
- }
- });
- }
- @Override
- public void onBackPressed() {
- DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
- if (drawer.isDrawerOpen(GravityCompat.START)) {
- drawer.closeDrawer(GravityCompat.START);
- } else {
- super.onBackPressed();
- }
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.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);
- }
- @SuppressWarnings("StatementWithEmptyBody")
- @Override
- public boolean onNavigationItemSelected(MenuItem item) {
- // Handle navigation view item clicks here.
- int id = item.getItemId();
- if (id == R.id.nav_camera) {
- // Handle the camera action
- } else if (id == R.id.nav_gallery) {
- } else if (id == R.id.nav_slideshow) {
- } else if (id == R.id.nav_manage) {
- }
- DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
- drawer.closeDrawer(GravityCompat.START);
- return true;
- }
- }
- #ini bagian xmlnya
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
- <TabHost
- android:id="@+id/tabHost"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_alignParentTop="true"
- android:layout_centerHorizontal="true">
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
- <TabWidget
- android:id="@android:id/tabs"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
- </TabWidget>
- <FrameLayout
- android:id="@android:id/tabcontent"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="@color/white">
- <LinearLayout
- android:id="@+id/tab2"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:padding="20dp">
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:id="@+id/btn_tindakan"
- android:text="Tindak siswa"
- android:background="@drawable/radius_button_asphalt"
- android:padding="15dp"
- android:layout_marginRight="20dp"
- android:layout_marginBottom="20dp"
- android:textColor="@color/white"
- android:drawableTop="@drawable/peluit" />
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:id="@+id/btn_pasal"
- android:layout_toRightOf="@+id/btn_tindakan"
- android:text="Pasal-Pasal"
- android:padding="15dp"
- android:layout_marginBottom="20dp"
- android:background="@drawable/radius_button_orange"
- android:textColor="@color/white"
- android:drawableTop="@drawable/buku_kebijakan"/>
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:id="@+id/btn_list_point"
- android:layout_marginRight="20dp"
- android:layout_below="@+id/btn_tindakan"
- android:text="point siswa"
- android:padding="15dp"
- android:background="@drawable/radius_button_turquoise"
- android:textColor="@color/white"
- android:drawableTop="@drawable/list_point"/>
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:id="@+id/btn_jadwal_osis"
- android:layout_below="@+id/btn_pasal"
- android:layout_toRightOf="@id/btn_list_point"
- android:text="jadwal osis"
- android:padding="15dp"
- android:background="@drawable/radius_button"
- android:textColor="@color/white"
- android:drawableTop="@drawable/jadwal_osis"/>
- </RelativeLayout>
- </LinearLayout>
- <LinearLayout
- android:id="@+id/tab1"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/abc"
- android:padding="15dp">
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="Hello World"
- android:textStyle="bold"/>
- </RelativeLayout>
- </LinearLayout>
- </FrameLayout>
- </LinearLayout>
- </TabHost>
- </LinearLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement