Last active
November 9, 2015 13:06
-
-
Save bubblek/e34c37a8ba45a46655d9 to your computer and use it in GitHub Desktop.
탐나로 Step3 Timeline CardView 구현
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
<android.support.v4.widget.SwipeRefreshLayout | |
android:id="@+id/oreum_content01_sly" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content"> | |
<ListView | |
android:id="@+id/oreum_content01_lv" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:background="@drawable/ly_step3_timeline" | |
android:divider="@android:color/transparent" | |
android:dividerHeight="16dp" | |
android:padding="16dp" /> | |
</android.support.v4.widget.SwipeRefreshLayout> | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:card_view="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:background="#FFFFFF" | |
card_view:cardElevation="1dp" | |
card_view:cardUseCompatPadding="true"> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:orientation="vertical" | |
android:padding="16dp"> | |
<com.chamodev.tamnaro.CustomTextView | |
android:id="@+id/step3_timeline_cv_title_tv" | |
... /> | |
<com.chamodev.tamnaro.CustomTextView | |
android:id="@+id/step3_timeline_cv_time_tv" | |
... /> | |
<ImageView | |
android:id="@+id/step3_timeline_cv_content_iv" | |
... /> | |
<com.chamodev.tamnaro.CustomTextView | |
android:id="@+id/step3_timeline_cv_content_tv" | |
... /> | |
<LinearLayout | |
... > | |
<ImageView | |
... /> | |
<com.chamodev.tamnaro.CustomTextView | |
android:id="@+id/step3_timeline_cv_like_tv" | |
... /> | |
<ImageView | |
... /> | |
<com.chamodev.tamnaro.CustomTextView | |
android:id="@+id/step3_timeline_cv_comment_tv" | |
... /> | |
</LinearLayout> | |
</LinearLayout> | |
</android.support.v7.widget.CardView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.chamodev.tamnaro.model; | |
public class TimelineContents { | |
private String title, time, content, imgsrc; | |
private int like, comment; | |
public TimelineContents() { | |
} | |
public String getTitle() { | |
return title; | |
} | |
public void setTitle(String title) { | |
this.title = title; | |
} | |
public String getTime() { | |
return time; | |
} | |
public void setTime(String time) { | |
this.time = time; | |
} | |
public String getContent() { | |
return content; | |
} | |
public void setContent(String content) { | |
this.content = content; | |
} | |
public String getImgsrc() { | |
return imgsrc; | |
} | |
public void setImgsrc(String imgsrc) { | |
this.imgsrc = imgsrc; | |
} | |
public int getLike() { | |
return like; | |
} | |
public void setLike(int like) { | |
this.like = like; | |
} | |
public int getComment() { | |
return comment; | |
} | |
public void setComment(int comment) { | |
this.comment = comment; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.chamodev.tamnaro.adapter; | |
... | |
public class TimelineListViewAdapter extends BaseAdapter { | |
private Context context; | |
private LayoutInflater inflater; | |
private List<TimelineContents> contentsList; | |
private ImageLoader imageLoader = ImageLoader.getInstance(); | |
public TimelineListViewAdapter(Context context, List<TimelineContents> contentsList) { | |
this.context = context; | |
this.contentsList = contentsList; | |
} | |
@Override | |
public int getCount() { | |
return contentsList.size(); | |
} | |
@Override | |
public Object getItem(int i) { | |
return contentsList.get(i); | |
} | |
@Override | |
public long getItemId(int i) { | |
return i; | |
} | |
@Override | |
public View getView(int i, View convertView, ViewGroup viewGroup) { | |
if (inflater == null) | |
inflater = (LayoutInflater) context | |
.getSystemService(Context.LAYOUT_INFLATER_SERVICE); | |
if (convertView == null) | |
convertView = inflater.inflate(R.layout.cardview_step3_timeline, null); | |
imageLoader.init(ImageLoaderConfiguration.createDefault(context)); | |
CustomTextView titleCtv = (CustomTextView) convertView.findViewById(R.id.step3_timeline_cv_title_tv); | |
CustomTextView timeCtv = (CustomTextView) convertView.findViewById(R.id.step3_timeline_cv_time_tv); | |
CustomTextView contentCtv = (CustomTextView) convertView.findViewById(R.id.step3_timeline_cv_content_tv); | |
ImageView contentIv = (ImageView) convertView.findViewById(R.id.step3_timeline_cv_content_iv); | |
CustomTextView likeCtv = (CustomTextView) convertView.findViewById(R.id.step3_timeline_cv_like_tv); | |
CustomTextView commentCtv = (CustomTextView) convertView.findViewById(R.id.step3_timeline_cv_comment_tv); | |
TimelineContents contents = contentsList.get(i); | |
titleCtv.setText(contents.getTitle()); | |
timeCtv.setText(contents.getTime()); | |
contentCtv.setText(contents.getContent()); | |
imageLoader.displayImage(contents.getImgsrc(), contentIv); | |
likeCtv.setText(String.valueOf(contents.getLike())); | |
commentCtv.setText(String.valueOf(contents.getComment())); | |
return convertView; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment