Skip to content

Commit 8d4d91f

Browse files
committed
Showing news source in list
Signed-off-by: Umair Khan <[email protected]>
1 parent 57ded56 commit 8d4d91f

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

App/src/main/java/in/ac/dtu/subtlenews/MainFragment.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,11 @@ public View getView(int position, View convertView, ViewGroup parent) {
226226
rowView = inflater.inflate(R.layout.row_list, null);
227227

228228
// set value into textview
229-
TextView textView = (TextView) rowView.findViewById(R.id.title_news);
229+
TextView newsTitle = (TextView) rowView.findViewById(R.id.title_news);
230+
TextView sourceName = (TextView) rowView.findViewById(R.id.source_news);
230231
try {
231-
textView.setText(selectedCategoryList.get(position).getString(TAG_TITLE));
232+
newsTitle.setText(selectedCategoryList.get(position).getString(TAG_TITLE));
233+
sourceName.setText(selectedCategoryList.get(position).getString(TAG_SOURCE));
232234
} catch (Exception e){
233235
e.printStackTrace();
234236
}

App/src/main/res/layout/row_list.xml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@
22

33
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
44
android:orientation="vertical" android:layout_width="match_parent"
5-
android:layout_height="match_parent"
5+
android:layout_height="60dp"
66
android:layout_margin="3dp" >
77

88
<TextView
99
android:id="@+id/title_news"
1010
android:layout_width="match_parent"
11-
android:layout_height="match_parent" />
11+
android:layout_height="wrap_content" />
12+
13+
<TextView
14+
android:id="@+id/source_news"
15+
android:layout_width="wrap_content"
16+
android:layout_height="wrap_content"
17+
android:layout_gravity="right"
18+
android:textSize="10sp"
19+
android:textColor="#BFBFBF"/>
1220

1321
</LinearLayout>

0 commit comments

Comments
 (0)