Skip to content

Commit 8d83c1a

Browse files
committed
Example
1 parent f69fc2b commit 8d83c1a

24 files changed

+590
-3
lines changed

app/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ dependencies {
2222
implementation fileTree(dir: 'libs', include: ['*.jar'])
2323
implementation 'com.android.support:appcompat-v7:28.0.0'
2424
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
25+
implementation 'com.android.support:support-v4:28.0.0'
26+
implementation 'com.android.support:design:28.0.0'
2527
testImplementation 'junit:junit:4.12'
2628
androidTestImplementation 'com.android.support.test:runner:1.0.2'
2729
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

app/src/main/AndroidManifest.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@
1010
android:supportsRtl="true"
1111
android:theme="@style/AppTheme">
1212
<activity
13-
android:name="com.dvinfosys.WidgetsExample.MainActivity"
13+
android:name=".MainActivity"
14+
android:label="@string/title_activity_home"/>
15+
<activity
16+
android:name=".Activity.HomeActivity"
17+
android:theme="@style/AppTheme.NoActionBar"
1418
android:configChanges="orientation|screenSize|keyboardHidden"
15-
android:windowSoftInputMode="stateAlwaysHidden"
16-
android:screenOrientation="portrait">
19+
android:screenOrientation="portrait"
20+
android:windowSoftInputMode="stateAlwaysHidden">
1721
<intent-filter>
1822
<action android:name="android.intent.action.MAIN" />
1923

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package com.dvinfosys.WidgetsExample.Activity;
2+
3+
import android.os.Bundle;
4+
import android.support.design.widget.NavigationView;
5+
import android.support.v4.app.Fragment;
6+
import android.support.v4.app.FragmentTransaction;
7+
import android.support.v4.view.GravityCompat;
8+
import android.support.v4.widget.DrawerLayout;
9+
import android.support.v7.app.ActionBarDrawerToggle;
10+
import android.support.v7.app.AppCompatActivity;
11+
import android.support.v7.widget.Toolbar;
12+
import android.view.Menu;
13+
import android.view.MenuItem;
14+
15+
import com.dvinfosys.WidgetsExample.Fragments.EditTextFragment;
16+
import com.dvinfosys.WidgetsExample.Fragments.TextViewFragment;
17+
import com.dvinfosys.WidgetsExample.R;
18+
19+
public class HomeActivity extends AppCompatActivity
20+
implements NavigationView.OnNavigationItemSelectedListener {
21+
22+
@Override
23+
protected void onCreate(Bundle savedInstanceState) {
24+
super.onCreate(savedInstanceState);
25+
setContentView(R.layout.activity_home);
26+
Toolbar toolbar = findViewById(R.id.toolbar);
27+
setSupportActionBar(toolbar);
28+
29+
DrawerLayout drawer = findViewById(R.id.drawer_layout);
30+
NavigationView navigationView = findViewById(R.id.nav_view);
31+
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
32+
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
33+
drawer.addDrawerListener(toggle);
34+
toggle.syncState();
35+
navigationView.setNavigationItemSelectedListener(this);
36+
}
37+
38+
@Override
39+
public void onBackPressed() {
40+
DrawerLayout drawer = findViewById(R.id.drawer_layout);
41+
if (drawer.isDrawerOpen(GravityCompat.START)) {
42+
drawer.closeDrawer(GravityCompat.START);
43+
} else {
44+
super.onBackPressed();
45+
}
46+
}
47+
48+
@Override
49+
public boolean onCreateOptionsMenu(Menu menu) {
50+
// Inflate the menu; this adds items to the action bar if it is present.
51+
getMenuInflater().inflate(R.menu.home, menu);
52+
return true;
53+
}
54+
55+
@Override
56+
public boolean onOptionsItemSelected(MenuItem item) {
57+
// Handle action bar item clicks here. The action bar will
58+
// automatically handle clicks on the Home/Up button, so long
59+
// as you specify a parent activity in AndroidManifest.xml.
60+
int id = item.getItemId();
61+
62+
//noinspection SimplifiableIfStatement
63+
if (id == R.id.action_settings) {
64+
return true;
65+
}
66+
67+
return super.onOptionsItemSelected(item);
68+
}
69+
70+
@SuppressWarnings("StatementWithEmptyBody")
71+
@Override
72+
public boolean onNavigationItemSelected(MenuItem item) {
73+
int id = item.getItemId();
74+
Fragment fragment = null;
75+
76+
if (id == R.id.nav_home) {
77+
78+
} else if (id == R.id.nav_textview) {
79+
fragment = new TextViewFragment();
80+
} else if (id == R.id.nav_edittext) {
81+
fragment = new EditTextFragment();
82+
} else if (id == R.id.nav_checkbox) {
83+
84+
} else if (id == R.id.nav_share) {
85+
86+
} else if (id == R.id.nav_send) {
87+
88+
}
89+
if (fragment != null) {
90+
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
91+
ft.replace(R.id.content_frame, fragment);
92+
ft.commit();
93+
}
94+
DrawerLayout drawer = findViewById(R.id.drawer_layout);
95+
drawer.closeDrawer(GravityCompat.START);
96+
return true;
97+
}
98+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.dvinfosys.WidgetsExample.Fragments;
2+
3+
import android.os.Bundle;
4+
import android.support.annotation.NonNull;
5+
import android.support.annotation.Nullable;
6+
import android.support.v4.app.Fragment;
7+
import android.view.LayoutInflater;
8+
import android.view.View;
9+
import android.view.ViewGroup;
10+
11+
import com.dvinfosys.WidgetsExample.R;
12+
13+
public class EditTextFragment extends Fragment {
14+
15+
@Override
16+
public View onCreateView(LayoutInflater inflater, ViewGroup container,
17+
Bundle savedInstanceState) {
18+
// Inflate the layout for this fragment
19+
return inflater.inflate(R.layout.fragment_edit_text, container, false);
20+
}
21+
@Override
22+
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
23+
super.onViewCreated(view, savedInstanceState);
24+
getActivity().setTitle("EditText");
25+
}
26+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.dvinfosys.WidgetsExample.Fragments;
2+
3+
import android.os.Bundle;
4+
import android.support.annotation.NonNull;
5+
import android.support.annotation.Nullable;
6+
import android.support.v4.app.Fragment;
7+
import android.view.LayoutInflater;
8+
import android.view.View;
9+
import android.view.ViewGroup;
10+
11+
import com.dvinfosys.WidgetsExample.R;
12+
13+
public class TextViewFragment extends Fragment {
14+
15+
@Override
16+
public View onCreateView(LayoutInflater inflater, ViewGroup container,
17+
Bundle savedInstanceState) {
18+
// Inflate the layout for this fragment
19+
return inflater.inflate(R.layout.fragment_text_view, container, false);
20+
}
21+
22+
@Override
23+
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
24+
super.onViewCreated(view, savedInstanceState);
25+
getActivity().setTitle("TextView");
26+
}
27+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24.0"
5+
android:viewportHeight="24.0">
6+
<path
7+
android:fillColor="#FF000000"
8+
android:pathData="M22,16V4c0,-1.1 -0.9,-2 -2,-2H8c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2zm-11,-4l2.03,2.71L16,11l4,5H8l3,-4zM2,6v14c0,1.1 0.9,2 2,2h14v-2H4V6H2z" />
9+
</vector>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24.0"
5+
android:viewportHeight="24.0">
6+
<path
7+
android:fillColor="#FF000000"
8+
android:pathData="M22.7,19l-9.1,-9.1c0.9,-2.3 0.4,-5 -1.5,-6.9 -2,-2 -5,-2.4 -7.4,-1.3L9,6 6,9 1.6,4.7C0.4,7.1 0.9,10.1 2.9,12.1c1.9,1.9 4.6,2.4 6.9,1.5l9.1,9.1c0.4,0.4 1,0.4 1.4,0l2.3,-2.3c0.5,-0.4 0.5,-1.1 0.1,-1.4z" />
9+
</vector>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24.0"
5+
android:viewportHeight="24.0">
6+
<path
7+
android:fillColor="#FF000000"
8+
android:pathData="M2.01,21L23,12 2.01,3 2,10l15,2 -15,2z" />
9+
</vector>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24.0"
5+
android:viewportHeight="24.0">
6+
<path
7+
android:fillColor="#FF000000"
8+
android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z" />
9+
</vector>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24.0"
5+
android:viewportHeight="24.0">
6+
<path
7+
android:fillColor="#FF000000"
8+
android:pathData="M4,6H2v14c0,1.1 0.9,2 2,2h14v-2H4V6zm16,-4H8c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2V4c0,-1.1 -0.9,-2 -2,-2zm-8,12.5v-9l6,4.5 -6,4.5z" />
9+
</vector>

0 commit comments

Comments
 (0)