diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 39139a6..3281651 100755
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -13,6 +13,7 @@
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 5d19981..ba7052b 100755
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,8 +1,5 @@
-
-
-
@@ -27,17 +24,7 @@
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 834ed9f..39f4ded 100755
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,7 +2,8 @@
-
+
+
diff --git a/app/build.gradle b/app/build.gradle
index 7bfcb74..f86df3b 100755
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 23
- buildToolsVersion "23.0.2"
+ buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.exun.test.navexpandablelist"
@@ -21,6 +21,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
+ compile 'com.android.support.constraint:constraint-layout:1.1.2'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index e7a90a8..6463ce5 100755
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -18,6 +18,7 @@
+
-
+
\ No newline at end of file
diff --git a/app/src/main/java/com/exun/test/navexpandablelist/MainActivity.java b/app/src/main/java/com/exun/test/navexpandablelist/MainActivity.java
index f0679f4..7212783 100755
--- a/app/src/main/java/com/exun/test/navexpandablelist/MainActivity.java
+++ b/app/src/main/java/com/exun/test/navexpandablelist/MainActivity.java
@@ -1,5 +1,6 @@
package com.exun.test.navexpandablelist;
+import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
@@ -7,6 +8,7 @@
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
+import android.widget.Button;
import android.widget.ExpandableListView;
import android.widget.Toast;
@@ -24,18 +26,31 @@ public class MainActivity extends AppCompatActivity implements ExpandableListVie
List listDataHeader;
HashMap> listDataChild;
+ //Second activity button declaration
+ Button secondActivityBtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
+ //assigning id to secondActivityBtn
+ secondActivityBtn=(Button)findViewById(R.id.secondActivityBtn);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowHomeEnabled(true);
initDrawer();
+
+ // setting onclickListener for secondActivityBtn
+ secondActivityBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent i= new Intent(MainActivity.this,SecondActivity.class);
+ startActivity(i);
+ }
+ });
}
private void initDrawer() {
diff --git a/app/src/main/java/com/exun/test/navexpandablelist/SecondActivity.java b/app/src/main/java/com/exun/test/navexpandablelist/SecondActivity.java
new file mode 100644
index 0000000..949c1df
--- /dev/null
+++ b/app/src/main/java/com/exun/test/navexpandablelist/SecondActivity.java
@@ -0,0 +1,136 @@
+package com.exun.test.navexpandablelist;
+
+import android.content.res.Resources;
+import android.support.v4.widget.DrawerLayout;
+import android.support.v7.app.ActionBarDrawerToggle;
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.support.v7.widget.Toolbar;
+import android.view.View;
+import android.widget.ExpandableListView;
+import android.widget.Toast;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+
+public class SecondActivity extends AppCompatActivity implements ExpandableListView.OnChildClickListener{
+
+ Toolbar toolbar;
+ private DrawerLayout drawer;
+ private ExpandableListView drawerList;
+ private ActionBarDrawerToggle actionBarDrawerToggle;
+ List listDataHeader;
+ HashMap> listDataChild;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_second);
+
+
+ toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+ getSupportActionBar().setDisplayShowHomeEnabled(true);
+
+ initDrawer();
+
+ }
+ private void initDrawer() {
+ drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
+
+ drawerList = (ExpandableListView) findViewById(R.id.left_drawer);
+
+ // preparing list data
+ prepareListData();
+
+ drawerList.setAdapter(new NavAdapter(this, listDataHeader, listDataChild));
+
+ drawerList.setOnChildClickListener(this);
+
+ actionBarDrawerToggle = new ActionBarDrawerToggle(this,drawer,toolbar,R.string.drawer_open , R.string.drawer_close ){
+
+ @Override
+ public void onDrawerClosed(View drawerView) {
+ // Code here will be triggered once the drawer closes as we don't want anything to happen so we leave this blank
+ super.onDrawerClosed(drawerView);
+ }
+
+ @Override
+ public void onDrawerOpened(View drawerView) {
+ // Code here will be triggered once the drawer open as we don't want anything to happen so we leave this blank
+
+ super.onDrawerOpened(drawerView);
+ }
+ };
+
+ //Setting the actionbarToggle to drawer layout
+ drawer.setDrawerListener(actionBarDrawerToggle);
+
+ //calling sync state is necessay or else your hamburger icon wont show up
+ actionBarDrawerToggle.syncState();
+ }
+
+ /*
+ * Preparing the list data
+ */
+ private void prepareListData() {
+ listDataHeader = new ArrayList();
+ listDataChild = new HashMap>();
+
+
+ // Adding headers
+ Resources res = getResources();
+ String[] headers = res.getStringArray(R.array.nav_drawer_labels);
+ listDataHeader = Arrays.asList(headers);
+
+ //Adding child data
+
+// //Dynamic method
+// for (int i =0; i listChild;
+// listChild = Arrays.asList(childData);
+//
+// //Add to hashMap
+// listDataChild.put(listDataHeader.get(i),listChild);
+// }
+
+ // Static method
+ List home,friends,notifs;
+ String[] shome,sfriends,snotifs;
+
+ shome = res.getStringArray(R.array.elements_home);
+ home = Arrays.asList(shome);
+
+ sfriends = res.getStringArray(R.array.elements_friends);
+ friends = Arrays.asList(sfriends);
+
+ snotifs = res.getStringArray(R.array.elements_notifs);
+ notifs = Arrays.asList(snotifs);
+
+ // Add to hashMap
+ listDataChild.put(listDataHeader.get(0), home); // Header, Child data
+ listDataChild.put(listDataHeader.get(1), friends);
+ listDataChild.put(listDataHeader.get(2), notifs);
+ }
+
+ @Override
+ public boolean onChildClick(ExpandableListView parent, View v,
+ int groupPosition, int childPosition, long id) {
+ Toast.makeText(
+ getApplicationContext(),
+ listDataHeader.get(groupPosition)
+ + " : "
+ + listDataChild.get(
+ listDataHeader.get(groupPosition)).get(
+ childPosition), Toast.LENGTH_SHORT)
+ .show();
+ return false;
+ }
+}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 69ac7a1..2196963 100755
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -28,9 +28,23 @@
android:layout_height="0dp"
android:layout_weight="1" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/list_item.xml b/app/src/main/res/layout/list_item.xml
index d03ebba..2796f8d 100755
--- a/app/src/main/res/layout/list_item.xml
+++ b/app/src/main/res/layout/list_item.xml
@@ -13,6 +13,7 @@
android:paddingTop="5dp"
android:text="Hello"
android:paddingBottom="5dp"
- android:paddingLeft="?android:attr/expandableListPreferredChildPaddingLeft" />
+ android:paddingLeft="?android:attr/expandableListPreferredChildPaddingLeft"
+ />
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index e0b366a..3be019c 100755
--- a/build.gradle
+++ b/build.gradle
@@ -3,9 +3,13 @@
buildscript {
repositories {
jcenter()
+ maven {
+ url 'https://maven.google.com/'
+ name 'Google'
+ }
}
dependencies {
- classpath 'com.android.tools.build:gradle:1.5.0'
+ classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@@ -15,6 +19,7 @@ buildscript {
allprojects {
repositories {
jcenter()
+ google()
}
}
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index f23df6e..50c7948 100755
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Wed Oct 21 11:34:03 PDT 2015
+#Thu Jun 21 00:31:35 IST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip