Skip to content

Commit e4223b8

Browse files
committed
joke item click add nick and time
1 parent 347fa19 commit e4223b8

File tree

2 files changed

+51
-7
lines changed

2 files changed

+51
-7
lines changed

app/src/main/java/com/github/zeng1990java/jiandan/adapter/JokeAdapter.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,12 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
7777
if (getItemViewType(position) == ITEM_LOAD_MORE){
7878
return;
7979
}
80+
81+
JokeModel jokeModel = getItem(position);
8082
ViewHolder vh = (ViewHolder) holder;
81-
vh.jokeContent.setText(getItem(position).getText_content());
83+
vh.jokeContent.setText(jokeModel.getText_content());
84+
vh.nickname.setText(jokeModel.getComment_author());
85+
vh.time.setText(jokeModel.getComment_date());
8286
}
8387

8488
@Override
@@ -97,6 +101,10 @@ static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickL
97101

98102
@Bind(R.id.joke_content)
99103
TextView jokeContent;
104+
@Bind(R.id.nickname)
105+
TextView nickname;
106+
@Bind(R.id.time)
107+
TextView time;
100108

101109
public ViewHolder(View itemView) {
102110
super(itemView);

app/src/main/res/layout/item_joke.xml

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,51 @@
1313
app:cardCornerRadius="2dp"
1414
>
1515

16-
<TextView
17-
android:id="@+id/joke_content"
16+
<LinearLayout
1817
android:layout_width="match_parent"
1918
android:layout_height="wrap_content"
19+
android:orientation="vertical"
2020
android:layout_gravity="center_vertical|left"
2121
android:padding="@dimen/item_padding"
22-
android:textColor="@color/primaryText"
23-
android:textSize="16dp"
24-
tools:text="南方的朋友们!我有个提议!既然你们今年冬天那么热,不如就取消寒假吧"
25-
/>
22+
>
23+
24+
<LinearLayout
25+
android:layout_width="match_parent"
26+
android:layout_height="wrap_content"
27+
android:orientation="horizontal"
28+
>
29+
<TextView
30+
android:id="@+id/nickname"
31+
android:layout_width="wrap_content"
32+
android:layout_height="wrap_content"
33+
android:textColor="@color/primaryText"
34+
android:textSize="18dp"
35+
tools:text="王大锤"
36+
/>
37+
38+
<TextView
39+
android:id="@+id/time"
40+
android:layout_width="wrap_content"
41+
android:layout_height="wrap_content"
42+
android:textColor="@color/secondaryText"
43+
android:layout_marginLeft="8dp"
44+
android:textSize="14dp"
45+
tools:text="1 小时前"
46+
/>
47+
</LinearLayout>
48+
49+
<TextView
50+
android:id="@+id/joke_content"
51+
android:layout_width="match_parent"
52+
android:layout_height="wrap_content"
53+
android:layout_marginTop="8dp"
54+
android:textColor="@color/secondaryText"
55+
android:textSize="16dp"
56+
tools:text="南方的朋友们!我有个提议!既然你们今年冬天那么热,不如就取消寒假吧"
57+
/>
58+
59+
</LinearLayout>
60+
61+
2662

2763
</android.support.v7.widget.CardView>

0 commit comments

Comments
 (0)