Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Todos los comentarios estan en el formato de Java o // o /* comentario multi linea */
- MainActivity.java
- package com.techcomputerworld.tcw.testactionbar;
- //import android.app.ActionBar;
- import android.support.v7.app.AppCompatActivity;
- import android.support.v7.app.ActionBar;
- import android.os.Bundle;
- import android.support.v7.widget.Toolbar;
- public class MainActivity extends AppCompatActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
- setSupportActionBar(myToolbar);
- ActionBar ab = getSupportActionBar();
- ab.setDisplayHomeAsUpEnabled(true);
- }
- }
- // Los XML los pongo aqui
- /*
- * Activity_main.xml
- */
- <?xml version="1.0" encoding="utf-8"?>
- <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:context="com.techcomputerworld.tcw.testactionbar.MainActivity">
- <android.support.v7.widget.Toolbar
- android:id="@+id/my_toolbar"
- android:layout_width="match_parent"
- android:layout_height="?attr/actionBarSize"
- android:background="?attr/colorPrimary"
- android:elevation="4dp"
- android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
- app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Hello World!"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintLeft_toLeftOf="parent"
- app:layout_constraintRight_toRightOf="parent"
- app:layout_constraintTop_toTopOf="parent" />
- </android.support.constraint.ConstraintLayout>
- /*
- * menu.xml
- */
- <?xml version="1.0" encoding="utf-8"?>
- <menu xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto">
- <item android:id="@+id/action_setting"
- android:title="@string/action_setting"
- android:orderInCategory="100"
- app:showAsAction="never"/>
- </menu>
- /*
- * build.gradle
- */
- apply plugin: 'com.android.application'
- android {
- compileSdkVersion 25
- buildToolsVersion "25.0.2"
- defaultConfig {
- applicationId "com.techcomputerworld.tcw.testactionbar"
- minSdkVersion 19
- targetSdkVersion 25
- versionCode 1
- versionName "1.0"
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
- }
- dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
- exclude group: 'com.android.support', module: 'support-annotations'
- })
- compile 'com.android.support:appcompat-v7:25.1.1'
- compile 'com.android.support.constraint:constraint-layout:1.0.2'
- testCompile 'junit:junit:4.12'
- }
- /*
- * strings.xml
- */
- <resources>
- <string name="app_name">TestActionBar</string>
- <string name="action_setting">Setting</string>
- </resources>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement