Skip to content

Commit aa0558d

Browse files
committed
Further extend example project
1 parent 1ff85cd commit aa0558d

4 files changed

Lines changed: 30 additions & 3 deletions

File tree

MPChartExample/res/layout/list_item.xml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,22 @@
2222
android:layout_below="@+id/tvName"
2323
android:layout_marginTop="3dp"
2424
android:text="Small Text"
25-
android:textSize="12dp" />
25+
android:textSize="12dp"
26+
android:layout_marginRight="10dp"
27+
android:layout_toLeftOf="@+id/tvNew"
28+
android:layout_toStartOf="@+id/tvNew" />
29+
30+
<TextView
31+
android:layout_width="wrap_content"
32+
android:layout_height="wrap_content"
33+
android:textAppearance="?android:attr/textAppearanceSmall"
34+
android:text="NEW"
35+
android:textColor="#FA6185"
36+
android:id="@+id/tvNew"
37+
android:textSize="12dp"
38+
android:layout_marginRight="5dp"
39+
android:layout_centerVertical="true"
40+
android:layout_alignParentRight="true"
41+
android:layout_alignParentEnd="true" />
2642

2743
</RelativeLayout>

MPChartExample/src/com/xxmassdeveloper/mpchartexample/notimportant/ContentItem.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public class ContentItem {
77

88
String name;
99
String desc;
10+
boolean isNew = false;
1011

1112
public ContentItem(String n, String d) {
1213
name = n;

MPChartExample/src/com/xxmassdeveloper/mpchartexample/notimportant/MainActivity.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,12 @@ protected void onCreate(Bundle savedInstanceState) {
121121
objects.add(new ContentItem(
122122
"Chart in ScrollView",
123123
"This demonstrates how to use a chart inside a ScrollView."));
124-
objects.add(new ContentItem(
124+
125+
ContentItem realm = new ContentItem(
125126
"Realm.io Database",
126-
"This demonstrates how to use this library with Realm.io mobile database."));
127+
"This demonstrates how to use this library with Realm.io mobile database.");
128+
realm.isNew = true;
129+
objects.add(realm);
127130

128131
MyAdapter adapter = new MyAdapter(this, objects);
129132

MPChartExample/src/com/xxmassdeveloper/mpchartexample/notimportant/MyAdapter.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
3434
convertView = LayoutInflater.from(getContext()).inflate(R.layout.list_item, null);
3535
holder.tvName = (TextView) convertView.findViewById(R.id.tvName);
3636
holder.tvDesc = (TextView) convertView.findViewById(R.id.tvDesc);
37+
holder.tvNew = (TextView) convertView.findViewById(R.id.tvNew);
3738

3839
convertView.setTag(holder);
3940

@@ -44,11 +45,17 @@ public View getView(int position, View convertView, ViewGroup parent) {
4445
holder.tvName.setText(c.name);
4546
holder.tvDesc.setText(c.desc);
4647

48+
if(c.isNew)
49+
holder.tvNew.setVisibility(View.VISIBLE);
50+
else
51+
holder.tvNew.setVisibility(View.GONE);
52+
4753
return convertView;
4854
}
4955

5056
private class ViewHolder {
5157

5258
TextView tvName, tvDesc;
59+
TextView tvNew;
5360
}
5461
}

0 commit comments

Comments
 (0)