Skip to content
This repository was archived by the owner on Jun 27, 2020. It is now read-only.

Commit fc056d2

Browse files
author
Evgeniy Kanivets
committed
Added Record, RecordAdapter classes and view_record.xml
1 parent fe809f9 commit fc056d2

File tree

3 files changed

+128
-0
lines changed

3 files changed

+128
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package com.blogspot.e_kanivets.moneytracker.adapter;
2+
3+
import android.content.Context;
4+
import android.view.LayoutInflater;
5+
import android.view.View;
6+
import android.view.ViewGroup;
7+
import android.widget.BaseAdapter;
8+
import android.widget.TextView;
9+
10+
import com.blogspot.e_kanivets.moneytracker.R;
11+
import com.blogspot.e_kanivets.moneytracker.model.Record;
12+
13+
import java.util.List;
14+
15+
/**
16+
* Created by eugene on 01/09/14.
17+
*/
18+
public class RecordAdapter extends BaseAdapter{
19+
20+
private Context context;
21+
private List<Record> records;
22+
23+
public RecordAdapter(Context context, List<Record> records) {
24+
this.context = context;
25+
this.records = records;
26+
}
27+
28+
@Override
29+
public int getCount() {
30+
return records.size();
31+
}
32+
33+
@Override
34+
public Object getItem(int position) {
35+
return records.get(position);
36+
}
37+
38+
@Override
39+
public long getItemId(int position) {
40+
return position;
41+
}
42+
43+
@Override
44+
public View getView(int position, View convertView, ViewGroup parent) {
45+
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
46+
convertView = layoutInflater.inflate(R.layout.view_record, parent);
47+
48+
TextView tvPrice = (TextView) convertView.findViewById(R.id.tv_price);
49+
TextView tvTitle = (TextView) convertView.findViewById(R.id.tv_title);
50+
TextView tvCategory = (TextView) convertView.findViewById(R.id.tv_category);
51+
52+
tvPrice.setText(records.get(position).getPrice());
53+
tvTitle.setText(records.get(position).getTitle());
54+
tvCategory.setText(records.get(position).getCategory());
55+
56+
return convertView;
57+
}
58+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.blogspot.e_kanivets.moneytracker.model;
2+
3+
/**
4+
* Created by eugene on 01/09/14.
5+
*/
6+
public class Record {
7+
8+
private String title;
9+
private String category;
10+
private String price;
11+
12+
public Record(String title, String category, String price) {
13+
this.title = title;
14+
this.category = category;
15+
this.price = price;
16+
}
17+
18+
public String getTitle() {
19+
return title;
20+
}
21+
22+
public String getCategory() {
23+
return category;
24+
}
25+
26+
public String getPrice() {
27+
return price;
28+
}
29+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:orientation="vertical" android:layout_width="match_parent"
5+
android:layout_height="match_parent">
6+
7+
<LinearLayout
8+
android:orientation="horizontal"
9+
android:layout_width="match_parent"
10+
android:layout_height="wrap_content"
11+
android:layout_gravity="center_horizontal"
12+
android:padding="10dp">
13+
14+
<TextView
15+
android:layout_width="match_parent"
16+
android:layout_height="wrap_content"
17+
android:text="New Text"
18+
android:id="@+id/tv_price"
19+
android:textSize="20dp"
20+
android:layout_weight="1"
21+
android:gravity="center" />
22+
23+
<TextView
24+
android:layout_width="match_parent"
25+
android:layout_height="wrap_content"
26+
android:text="New Text"
27+
android:id="@+id/tv_title"
28+
android:textSize="20dp"
29+
android:layout_weight="1"
30+
android:gravity="center" />
31+
32+
<TextView
33+
android:layout_width="match_parent"
34+
android:layout_height="wrap_content"
35+
android:text="New Text"
36+
android:id="@+id/tv_category"
37+
android:textSize="20dp"
38+
android:layout_weight="1"
39+
android:gravity="center" />
40+
</LinearLayout>
41+
</LinearLayout>

0 commit comments

Comments
 (0)