Commit f68f603e authored by Pearl Jen Santos's avatar Pearl Jen Santos

created a layout for the settings but has no corresponding activity. Please...

created a layout for the settings but has no corresponding activity. Please don't copy anything else as I am trying to fix the navigation drawer.
parent d9d26fdd
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<ConfirmationsSetting value="0" id="Add" /> <ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" /> <ConfirmationsSetting value="0" id="Remove" />
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">
......
...@@ -27,6 +27,7 @@ import android.view.View; ...@@ -27,6 +27,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
...@@ -41,31 +42,32 @@ public class ActionBarAttempt extends AppCompatActivity { ...@@ -41,31 +42,32 @@ public class ActionBarAttempt extends AppCompatActivity {
private CharSequence mDrawerTitle; private CharSequence mDrawerTitle;
private CharSequence mTitle; private CharSequence mTitle;
private String[] options; private String[] options;
private int[] optionIcons = {R.mipmap.ic_search, R.mipmap.ic_search, R.mipmap.ic_search, R.mipmap.ic_settings, R.mipmap.ic_logout};;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_action_bar_attempt); setContentView(R.layout.activity_action_bar_attempt);
//setting the toolbar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
final ActionBar actionBar = getSupportActionBar();
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true); actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayShowTitleEnabled(true);
toolbar.setNavigationIcon(R.drawable.ic_action_menu); toolbar.setNavigationIcon(R.drawable.ic_action_menu);
mTitle = mDrawerTitle = "About"; mTitle = mDrawerTitle = "About";
options = getResources().getStringArray(R.array.options); options = getResources().getStringArray(R.array.options);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); //mDrawerList = (ListView) findViewById(R.id.left_drawer);
mDrawerList = (ListView) findViewById(R.id.left_drawer);
// set up the drawer's list view with items and click listener // set up the drawer's list view with items and click listener
mDrawerList.setAdapter(new ArrayAdapter<String>(this, // mDrawerList.setAdapter(new CustomAdapter(this,options, optionIcons));
R.layout.custom_draw_item, options)); // mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
// enable ActionBar app icon to behave as action to toggle nav drawer // enable ActionBar app icon to behave as action to toggle nav drawer
...@@ -73,13 +75,13 @@ public class ActionBarAttempt extends AppCompatActivity { ...@@ -73,13 +75,13 @@ public class ActionBarAttempt extends AppCompatActivity {
// ActionBarDrawerToggle ties together the the proper interactions // ActionBarDrawerToggle ties together the the proper interactions
// between the sliding drawer and the action bar app icon // between the sliding drawer and the action bar app icon
mDrawerToggle = new ActionBarDrawerToggle( // mDrawerToggle = new ActionBarDrawerToggle(
this, /* host Activity */ // this, /* host Activity */
mDrawerLayout, /* DrawerLayout object */ // mDrawerLayout, /* DrawerLayout object */
R.drawable.ic_action_menu, /* nav drawer image to replace 'Up' caret */ // R.drawable.ic_action_menu, /* nav drawer image to replace 'Up' caret */
R.string.drawer_open, /* "open drawer" description for accessibility */ // R.string.drawer_open, /* "open drawer" description for accessibility */
R.string.drawer_close /* "close drawer" description for accessibility */ // R.string.drawer_close /* "close drawer" description for accessibility */
); // )
// { // {
// public void onDrawerClosed(View view) { // public void onDrawerClosed(View view) {
// actionBar.setTitle(mTitle); // actionBar.setTitle(mTitle);
...@@ -91,7 +93,7 @@ public class ActionBarAttempt extends AppCompatActivity { ...@@ -91,7 +93,7 @@ public class ActionBarAttempt extends AppCompatActivity {
// invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() // invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
// } // }
// }; // };
mDrawerLayout.setDrawerListener(mDrawerToggle); // mDrawerLayout.setDrawerListener(mDrawerToggle);
if (savedInstanceState == null) { if (savedInstanceState == null) {
...@@ -120,8 +122,14 @@ public class ActionBarAttempt extends AppCompatActivity { ...@@ -120,8 +122,14 @@ public class ActionBarAttempt extends AppCompatActivity {
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
// The action bar home/up action should open or close the drawer. // The action bar home/up action should open or close the drawer.
// ActionBarDrawerToggle will take care of this. // ActionBarDrawerToggle will take care of this.
if (mDrawerToggle.onOptionsItemSelected(item)) { // if (mDrawerToggle.onOptionsItemSelected(item)) {
return true; // return true;
// }
switch(item.getItemId()){
case android.R.id.home:
mDrawerLayout.openDrawer(GravityCompat.START);
return true;
} }
// Fragment fragment = null; // Fragment fragment = null;
// Bundle args = new Bundle(); // Bundle args = new Bundle();
...@@ -148,7 +156,7 @@ public class ActionBarAttempt extends AppCompatActivity { ...@@ -148,7 +156,7 @@ public class ActionBarAttempt extends AppCompatActivity {
// return super.onOptionsItemSelected(item); // return super.onOptionsItemSelected(item);
// } // }
return true; return super.onOptionsItemSelected(item);
} }
/* The click listner for ListView in the navigation drawer */ /* The click listner for ListView in the navigation drawer */
...@@ -166,7 +174,7 @@ public class ActionBarAttempt extends AppCompatActivity { ...@@ -166,7 +174,7 @@ public class ActionBarAttempt extends AppCompatActivity {
switch(position){ switch(position){
case 0: case 0:
Fragment fa = new SearchFragment(); fragment = new SearchFragment();
break; break;
case 1: case 1:
fragment = new Schedules(); fragment = new Schedules();
...@@ -227,6 +235,53 @@ public class ActionBarAttempt extends AppCompatActivity { ...@@ -227,6 +235,53 @@ public class ActionBarAttempt extends AppCompatActivity {
} }
class CustomAdapter extends BaseAdapter {
String[] options;
Context context;
int[] imageID;
private static LayoutInflater inflater = null;
public CustomAdapter(Context mainActivity,String[] optionsList, int[] optionIcons){
options = optionsList;
context = mainActivity;
imageID = optionIcons;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
return 0;
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
public class Holder{
ImageView img;
TextView tv;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Holder holder = new Holder();
View rowView;
rowView = inflater.inflate(R.layout.custom_draw_item, null);
holder.tv = (TextView) rowView.findViewById(R.id.nav_item);
holder.img = (ImageView) rowView.findViewById(R.id.list_icon);
holder.tv.setText(options[position]);
holder.img.setImageResource(imageID[position]);
return rowView;
}
}
......
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid
android:color="@color/deep_orange_500"/>
<size
android:height="1dp"
android:width="70dp"/>
</shape>
\ No newline at end of file
...@@ -25,12 +25,22 @@ ...@@ -25,12 +25,22 @@
/> />
</LinearLayout> </LinearLayout>
<!-- The navigation drawer --> <!-- The navigation drawer -->
<ListView android:id="@+id/left_drawer" <!--<ListView android:id="@+id/left_drawer"-->
android:layout_width="320dp" <!--android:layout_width="320dp"-->
<!--android:layout_height="match_parent"-->
<!--android:layout_gravity="start"-->
<!--android:choiceMode="singleChoice"-->
<!--android:divider="@android:color/transparent"-->
<!--android:dividerHeight="0dp"-->
<!--android:background="@color/deep_orange_300"/>-->
<android.support.design.widget.NavigationView
android:id="@+id/left_drawer"
android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="start" android:layout_gravity="start"
android:choiceMode="singleChoice" android:background="@color/deep_orange_300"
android:divider="@android:color/transparent" app:menu="@menu/drawer_view"
android:dividerHeight="0dp" />
android:background="@color/deep_orange_300"/>
</android.support.v4.widget.DrawerLayout> </android.support.v4.widget.DrawerLayout>
<TextView xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1" android:id="@android:id/text1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent">
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:gravity="center_vertical"
android:paddingLeft="16dp" <ImageView
android:paddingRight="16dp" android:layout_width="wrap_content"
android:textColor="#fff" android:layout_height="wrap_content"
android:background="?android:attr/activatedBackgroundIndicator" android:id="@+id/list_icon"
android:minHeight="?android:attr/listPreferredItemHeightSmall"/> android:layout_alignParentLeft="true"
android:layout_centerVertical="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="@+id/nav_item"
android:layout_toRightOf="@id/list_icon"
android:layout_centerVertical="true"
android:textSize="15sp"/>
</RelativeLayout>
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_gravity="center"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="10dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="SORT AVAILABLE TRIPS BY"
android:id="@+id/textView4"
android:layout_marginBottom="10dp"
android:drawableBottom="@drawable/underline"/>
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:id="@+id/spinner"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="CLEAR DATA"
android:layout_marginBottom="10dp"
android:id="@+id/textView5"
android:drawableBottom="@drawable/underline"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:text="Clear Search Data"
android:id="@+id/clearSearchData"
android:drawableBottom="@drawable/underline" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Clear Past Trips"
android:id="@+id/clearPastTrips"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Version"
android:layout_marginBottom="10dp"
android:id="@+id/versionLabel" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="V.02"
android:layout_marginBottom="10dp"
android:id="@+id/textView7" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item
android:id="@+id/search"
android:icon="@mipmap/ic_search"
android:title="Search"/>
<item
android:id="@+id/editProfile"
android:icon="@mipmap/ic_new_profile"
android:title="Edit Profile"/>
<item
android:id="@+id/viewPastTrips"
android:icon="@mipmap/ic_search"
android:title="View Past Trips"/>
<item
android:id="@+id/settings"
android:icon="@mipmap/ic_settings"
android:title="Settings"/>
<item
android:id="@+id/logout"
android:icon="@mipmap/ic_logout"
android:title="Log Out"/>
</group>
</menu>
\ No newline at end of file
...@@ -16,6 +16,15 @@ ...@@ -16,6 +16,15 @@
<item>Log Out</item> <item>Log Out</item>
</string-array> </string-array>
<!--<integer-array name="optionIcons">-->
<!--<item>@mipmap/ic_search</item>-->
<!--<item>@mipmap/ic_search</item>-->
<!--<item>@mipmap/ic_new_profile</item>-->
<!--<item>@mipmap/ic_search</item>-->
<!--<item>@mipmap/ic_settings</item>-->
<!--<item>@mipmap/ic_logout</item>-->
<!--</integer-array>-->
<string-array name="list"> <string-array name="list">
<item>Sched1</item> <item>Sched1</item>
<item>Sched2</item> <item>Sched2</item>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment