Commit 15ebe070 by Paktalin

activity order wine customized

parent c182e994
package com.example.paktalin.lavina; package com.example.paktalin.lavina;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.widget.ExpandableListView; import android.widget.ExpandableListView;
...@@ -21,6 +23,7 @@ public class OrderActivity extends AppCompatActivity { ...@@ -21,6 +23,7 @@ public class OrderActivity extends AppCompatActivity {
ExpandableListView expListView; ExpandableListView expListView;
List<String> listDataHeader; List<String> listDataHeader;
HashMap<String, List<String>> listDataChild; HashMap<String, List<String>> listDataChild;
Bitmap[] colorImages;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -30,15 +33,28 @@ public class OrderActivity extends AppCompatActivity { ...@@ -30,15 +33,28 @@ public class OrderActivity extends AppCompatActivity {
expListView = findViewById(R.id.expandable_list_view); expListView = findViewById(R.id.expandable_list_view);
prepareListData(); prepareListData();
prepareImages();
listAdapter = new ExpandableListAdapter(this, listDataHeader, listDataChild); listAdapter = new ExpandableListAdapter(this, listDataHeader, listDataChild, colorImages);
// setting list adapter
expListView.setAdapter(listAdapter); expListView.setAdapter(listAdapter);
} }
private void prepareImages() {
colorImages = new Bitmap[9];
colorImages[0] = BitmapFactory.decodeResource(getResources(), R.drawable.color1);
colorImages[1] = BitmapFactory.decodeResource(getResources(), R.drawable.color2);
colorImages[2] = BitmapFactory.decodeResource(getResources(), R.drawable.color3);
colorImages[3] = BitmapFactory.decodeResource(getResources(), R.drawable.color4);
colorImages[4] = BitmapFactory.decodeResource(getResources(), R.drawable.color5);
colorImages[5] = BitmapFactory.decodeResource(getResources(), R.drawable.color6);
colorImages[6] = BitmapFactory.decodeResource(getResources(), R.drawable.color7);
colorImages[7] = BitmapFactory.decodeResource(getResources(), R.drawable.color8);
colorImages[8] = BitmapFactory.decodeResource(getResources(), R.drawable.color9);
}
private void prepareHeadersData() { private void prepareHeadersData() {
String[] groups = new String[] {"Color", "Brand", "Price", "Year", "Strength", "Country", "Title", "Type", "Variety"}; String[] groups = new String[] {"COLOR", "BRAND", "PRICE", "YEAR", "STRENGTH", "COUNTRY",
"TITLE", "TYPE", "VARIETY"};
listDataHeader = new ArrayList<>(); listDataHeader = new ArrayList<>();
listDataHeader.addAll(Arrays.asList(groups)); listDataHeader.addAll(Arrays.asList(groups));
} }
...@@ -49,7 +65,9 @@ public class OrderActivity extends AppCompatActivity { ...@@ -49,7 +65,9 @@ public class OrderActivity extends AppCompatActivity {
listDataChild = new HashMap<>(); listDataChild = new HashMap<>();
List<String> colors = new ArrayList<>(); List<String> colors = new ArrayList<>();
colors.addAll(Arrays.asList("Gray", "Orange", "Red whine", "Rosé", "Tawny", "White wine", "Yellow")); colors.addAll(Arrays.asList("Light-Bodied Red Wine", "Medium-Bodied Red Wine",
"Full-Bodied Red Wine", "Old Red Wine", "Rosé Wine", "Light-Bodied White Wine",
"Medium-Bodied White Wine", "Full-Bodied White Wine", "Old White Wine"));
List<String> brands = new ArrayList<>(); List<String> brands = new ArrayList<>();
List<String> prices = new ArrayList<>(); List<String> prices = new ArrayList<>();
......
package com.example.paktalin.lavina.adapters; package com.example.paktalin.lavina.adapters;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter; import android.widget.BaseExpandableListAdapter;
import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.example.paktalin.lavina.R; import com.example.paktalin.lavina.R;
...@@ -23,12 +25,14 @@ public class ExpandableListAdapter extends BaseExpandableListAdapter { ...@@ -23,12 +25,14 @@ public class ExpandableListAdapter extends BaseExpandableListAdapter {
private List<String> _listDataHeader; // header titles private List<String> _listDataHeader; // header titles
// child data in format of header title, child title // child data in format of header title, child title
private HashMap<String, List<String>> _listDataChild; private HashMap<String, List<String>> _listDataChild;
Bitmap[] colorImages;
public ExpandableListAdapter(Context context, List<String> listDataHeader, public ExpandableListAdapter(Context context, List<String> listDataHeader,
HashMap<String, List<String>> listChildData) { HashMap<String, List<String>> listChildData, Bitmap[] colorImages) {
this._context = context; this._context = context;
this._listDataHeader = listDataHeader; this._listDataHeader = listDataHeader;
this._listDataChild = listChildData; this._listDataChild = listChildData;
this.colorImages = colorImages;
} }
@Override @Override
...@@ -43,8 +47,7 @@ public class ExpandableListAdapter extends BaseExpandableListAdapter { ...@@ -43,8 +47,7 @@ public class ExpandableListAdapter extends BaseExpandableListAdapter {
} }
@Override @Override
public View getChildView(int groupPosition, final int childPosition, public View getChildView(int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
boolean isLastChild, View convertView, ViewGroup parent) {
final String childText = (String) getChild(groupPosition, childPosition); final String childText = (String) getChild(groupPosition, childPosition);
...@@ -54,8 +57,11 @@ public class ExpandableListAdapter extends BaseExpandableListAdapter { ...@@ -54,8 +57,11 @@ public class ExpandableListAdapter extends BaseExpandableListAdapter {
convertView = infalInflater.inflate(R.layout.list_item, null); convertView = infalInflater.inflate(R.layout.list_item, null);
} }
TextView txtListChild = convertView TextView txtListChild = convertView.findViewById(R.id.lblListItem);
.findViewById(R.id.lblListItem); if (groupPosition == 0) {
ImageView imageView = convertView.findViewById(R.id.image_item);
imageView.setImageBitmap(colorImages[childPosition]);
}
txtListChild.setText(childText); txtListChild.setText(childText);
return convertView; return convertView;
...@@ -92,8 +98,7 @@ public class ExpandableListAdapter extends BaseExpandableListAdapter { ...@@ -92,8 +98,7 @@ public class ExpandableListAdapter extends BaseExpandableListAdapter {
convertView = infalInflater.inflate(R.layout.list_group, null); convertView = infalInflater.inflate(R.layout.list_group, null);
} }
TextView lblListHeader = convertView TextView lblListHeader = convertView.findViewById(R.id.lblListHeader);
.findViewById(R.id.lblListHeader);
lblListHeader.setTypeface(null, Typeface.BOLD); lblListHeader.setTypeface(null, Typeface.BOLD);
lblListHeader.setText(headerTitle); lblListHeader.setText(headerTitle);
......

1.84 KB | W: | H:

1.86 KB | W: | H:

app/src/main/res/drawable/arrow_right.png
app/src/main/res/drawable/arrow_right.png
app/src/main/res/drawable/arrow_right.png
app/src/main/res/drawable/arrow_right.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -22,16 +22,59 @@ ...@@ -22,16 +22,59 @@
</RelativeLayout> </RelativeLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/list_view_layout"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="450dp"
android:layout_below="@id/header" android:layout_below="@id/header"
android:background="@android:color/transparent"> android:background="@android:color/white">
<ExpandableListView <ExpandableListView
android:id="@+id/expandable_list_view" android:id="@+id/expandable_list_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent"
android:divider="@color/colorPrimaryDark"
android:dividerHeight="1dp"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/list_view_layout"
android:background="@android:color/transparent"
android:layout_alignParentBottom="true"
android:padding="20dp">
<TextView
android:id="@+id/found"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="103 results found"
android:layout_centerVertical="true"
android:textSize="16dp"
android:textColor="@android:color/white"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Proceed"
android:background="@android:color/transparent"
android:layout_centerVertical="true"
android:layout_marginEnd="5dp"
android:textColor="@android:color/white"
android:layout_toStartOf="@+id/arrow"
android:layout_toLeftOf="@+id/arrow"
android:layout_marginRight="5dp" />
<ImageView
android:id="@+id/arrow"
android:layout_width="10dp"
android:layout_height="20dp"
android:background="@drawable/arrow_right"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
</RelativeLayout> </RelativeLayout>
</RelativeLayout> </RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="70dp"
android:orientation="vertical" android:orientation="vertical"
android:padding="8dp" android:padding="10dp"
android:background="#000000"> android:background="@android:color/transparent">
<TextView <TextView
android:id="@+id/lblListHeader" android:id="@+id/lblListHeader"
android:layout_width="fill_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="?android:attr/expandableListPreferredItemPaddingLeft"
android:textSize="17dp" android:textSize="17dp"
android:textColor="#f9f93d" /> android:gravity="center"
android:textColor="@color/colorPrimaryDark" />
</LinearLayout> </LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="55dip" android:layout_height="50dp"
android:orientation="vertical" > android:orientation="vertical"
android:background="@android:color/white">
<ImageView
android:id="@+id/image_item"
android:layout_width="50dp"
android:layout_height="50dp" />
<TextView <TextView
android:id="@+id/lblListItem" android:id="@+id/lblListItem"
android:layout_width="fill_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@+id/image_item"
android:layout_toRightOf="@+id/image_item"
android:layout_marginStart="15dp"
android:text="Red wine"
android:textColor="@color/colorPrimaryDark"
android:textSize="18sp"
android:layout_marginLeft="20dp" />
<CheckBox
android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="17dip" android:layout_marginStart="20dp"
android:paddingTop="5dp" android:layout_marginLeft="20dp"
android:paddingBottom="5dp" android:layout_alignParentEnd="true"
android:paddingLeft="?android:attr/expandableListPreferredChildPaddingLeft" /> android:layout_centerVertical="true"
android:layout_marginEnd="20dp"
android:layout_alignParentRight="true" />
</LinearLayout> </RelativeLayout>
\ No newline at end of file \ No newline at end of file
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 sign in to comment