Commit 15ebe070 by Paktalin

activity order wine customized

parent c182e994
package com.example.paktalin.lavina;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ExpandableListView;
......@@ -21,6 +23,7 @@ public class OrderActivity extends AppCompatActivity {
ExpandableListView expListView;
List<String> listDataHeader;
HashMap<String, List<String>> listDataChild;
Bitmap[] colorImages;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -30,15 +33,28 @@ public class OrderActivity extends AppCompatActivity {
expListView = findViewById(R.id.expandable_list_view);
prepareListData();
prepareImages();
listAdapter = new ExpandableListAdapter(this, listDataHeader, listDataChild);
// setting list adapter
listAdapter = new ExpandableListAdapter(this, listDataHeader, listDataChild, colorImages);
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() {
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.addAll(Arrays.asList(groups));
}
......@@ -49,7 +65,9 @@ public class OrderActivity extends AppCompatActivity {
listDataChild = new HashMap<>();
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> prices = new ArrayList<>();
......
package com.example.paktalin.lavina.adapters;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.paktalin.lavina.R;
......@@ -23,12 +25,14 @@ public class ExpandableListAdapter extends BaseExpandableListAdapter {
private List<String> _listDataHeader; // header titles
// child data in format of header title, child title
private HashMap<String, List<String>> _listDataChild;
Bitmap[] colorImages;
public ExpandableListAdapter(Context context, List<String> listDataHeader,
HashMap<String, List<String>> listChildData) {
HashMap<String, List<String>> listChildData, Bitmap[] colorImages) {
this._context = context;
this._listDataHeader = listDataHeader;
this._listDataChild = listChildData;
this.colorImages = colorImages;
}
@Override
......@@ -43,8 +47,7 @@ public class ExpandableListAdapter extends BaseExpandableListAdapter {
}
@Override
public View getChildView(int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
public View getChildView(int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
final String childText = (String) getChild(groupPosition, childPosition);
......@@ -54,8 +57,11 @@ public class ExpandableListAdapter extends BaseExpandableListAdapter {
convertView = infalInflater.inflate(R.layout.list_item, null);
}
TextView txtListChild = convertView
.findViewById(R.id.lblListItem);
TextView txtListChild = convertView.findViewById(R.id.lblListItem);
if (groupPosition == 0) {
ImageView imageView = convertView.findViewById(R.id.image_item);
imageView.setImageBitmap(colorImages[childPosition]);
}
txtListChild.setText(childText);
return convertView;
......@@ -92,8 +98,7 @@ public class ExpandableListAdapter extends BaseExpandableListAdapter {
convertView = infalInflater.inflate(R.layout.list_group, null);
}
TextView lblListHeader = convertView
.findViewById(R.id.lblListHeader);
TextView lblListHeader = convertView.findViewById(R.id.lblListHeader);
lblListHeader.setTypeface(null, Typeface.BOLD);
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 @@
</RelativeLayout>
<RelativeLayout
android:id="@+id/list_view_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="450dp"
android:layout_below="@id/header"
android:background="@android:color/transparent">
android:background="@android:color/white">
<ExpandableListView
android:id="@+id/expandable_list_view"
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>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_height="70dp"
android:orientation="vertical"
android:padding="8dp"
android:background="#000000">
android:padding="10dp"
android:background="@android:color/transparent">
<TextView
android:id="@+id/lblListHeader"
android:layout_width="fill_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="?android:attr/expandableListPreferredItemPaddingLeft"
android:textSize="17dp"
android:textColor="#f9f93d" />
android:gravity="center"
android:textColor="@color/colorPrimaryDark" />
</LinearLayout>
\ No newline at end of file
<?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_height="55dip"
android:orientation="vertical" >
android:layout_height="50dp"
android:orientation="vertical"
android:background="@android:color/white">
<ImageView
android:id="@+id/image_item"
android:layout_width="50dp"
android:layout_height="50dp" />
<TextView
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:textSize="17dip"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:paddingLeft="?android:attr/expandableListPreferredChildPaddingLeft" />
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="20dp"
android:layout_alignParentRight="true" />
</LinearLayout>
\ No newline at end of file
</RelativeLayout>
\ 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