Commit 6f571bf2 by Paktalin

wine listview added

parent 4980a9ba
......@@ -3,9 +3,8 @@ package com.example.paktalin.lavina;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.design.widget.Snackbar;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
......@@ -13,6 +12,8 @@ import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListView;
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
......@@ -21,6 +22,12 @@ public class MainActivity extends AppCompatActivity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WineAdapter adapter = new WineAdapter(MainActivity.this);
ListView listView = findViewById(R.id.list_view);
listView.setAdapter(adapter);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
......
package com.example.paktalin.lavina;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
/**
* Created by Paktalin on 14/05/2018.
*/
public class WineAdapter extends BaseAdapter {
private LayoutInflater inflater;
WineAdapter(Context context) {
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
return 8;
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = inflater.inflate(R.layout.wine_item, null);
}
return convertView;
}
}
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
......@@ -7,6 +7,51 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.paktalin.lavina.MainActivity"
tools:showIn="@layout/app_bar_main">
tools:showIn="@layout/app_bar_main"
android:background="@drawable/background1">
</android.support.constraint.ConstraintLayout>
<LinearLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="40dp">
<Button
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="All"
android:background="@color/transparent_red"
android:textColor="@android:color/white"/>
<Button
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:text="Red" />
<Button
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:text="White" />
<Button
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:text="Sparkling" />
</LinearLayout>
<ListView
android:id="@+id/list_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tabs">
</ListView>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="100dp"
android:padding="10dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@+id/wine_sample">
<TextView
android:id="@+id/wine_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Two gates 2012"
android:textColor="@color/colorPrimaryDark"
android:textSize="16sp"
android:textStyle="bold|italic"
android:layout_marginLeft="20dp" />
<TextView
android:id="@+id/wine_brand"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/wine_title"
android:textColor="@color/colorPrimaryDark"
android:textStyle="bold|italic"
android:text="Chardonnay"
android:textSize="16sp"
android:layout_alignLeft="@+id/wine_title" />
</RelativeLayout>
<ImageView
android:id="@+id/wine_sample"
android:layout_width="30dp"
android:layout_height="80dp"
android:background="@drawable/wine1"
android:layout_marginStart="10dp"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp" />
<TextView
android:id="@+id/price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toStartOf="@+id/arrow"
android:text="182 €"
android:textSize="25sp"
android:textStyle="italic"
android:layout_centerVertical="true"
android:layout_marginEnd="20dp"/>
<ImageButton
android:id="@+id/arrow"
android:layout_width="13dp"
android:layout_height="22dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="20dp"
android:background="@drawable/arrow_right"
android:layout_marginRight="30dp"
android:layout_alignParentRight="true" />
</RelativeLayout>
\ No newline at end of file
......@@ -3,4 +3,7 @@
<color name="colorPrimary">#C41E32</color>
<color name="colorPrimaryDark">#4E0707</color>
<color name="colorAccent">#000</color>
<color name="transparent_black">#99000000</color>
<color name="transparent_red">#CC4E0707</color>
</resources>
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