Permalink
Browse files

update sample ,change ComplexViewMF DataType from String to ComplexIt…

…emEntity
  • Loading branch information...
1 parent 683c0b5 commit 94db3001b6538fae0c038a44f4a14f05647918f5 @gongwen committed Dec 27, 2016
@@ -0,0 +1,42 @@
+package com.gw.marquee;
+
+/**
+ * Created by GongWen on 16/12/27.
+ */
+
+public class ComplexItemEntity {
+
+ private String title;
+ private String secondTitle;
+ private String time;
+
+ public ComplexItemEntity(String title, String secondTitle, String time) {
+ this.title = title;
+ this.secondTitle = secondTitle;
+ this.time = time;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getSecondTitle() {
+ return secondTitle;
+ }
+
+ public void setSecondTitle(String secondTitle) {
+ this.secondTitle = secondTitle;
+ }
+
+ public String getTime() {
+ return time;
+ }
+
+ public void setTime(String time) {
+ this.time = time;
+ }
+}
@@ -3,10 +3,11 @@
import android.content.Context;
import android.view.LayoutInflater;
import android.widget.RelativeLayout;
+import android.widget.TextView;
import com.gongwen.marqueen.MarqueeFactory;
-public class ComplexViewMF extends MarqueeFactory<RelativeLayout, String> {
+public class ComplexViewMF extends MarqueeFactory<RelativeLayout, ComplexItemEntity> {
private LayoutInflater inflater;
public ComplexViewMF(Context mContext) {
@@ -15,8 +16,11 @@ public ComplexViewMF(Context mContext) {
}
@Override
- public RelativeLayout generateMarqueeItemView(String data) {
+ public RelativeLayout generateMarqueeItemView(ComplexItemEntity data) {
RelativeLayout mView = (RelativeLayout) inflater.inflate(R.layout.complex_view, null);
+ ((TextView) mView.findViewById(R.id.title)).setText(data.getTitle());
+ ((TextView) mView.findViewById(R.id.secondTitle)).setText(data.getSecondTitle());
+ ((TextView) mView.findViewById(R.id.time)).setText(data.getTime());
return mView;
}
}
@@ -9,6 +9,7 @@
import com.gongwen.marqueen.MarqueeFactory;
import com.gongwen.marqueen.MarqueeView;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -73,8 +74,12 @@ public void onItemClickListener(MarqueeFactory.ViewHolder<TextView, String> hold
marqueeView4.setMarqueeFactory(marqueeFactory4);
marqueeView4.startFlipping();
- MarqueeFactory<RelativeLayout, String> marqueeFactory5 = new ComplexViewMF(this);
- marqueeFactory5.setData(datas);
+ List<ComplexItemEntity> complexDatas = new ArrayList<>();
+ for (int i = 0; i < 5; i++) {
+ complexDatas.add(new ComplexItemEntity("标题 " + i, "副标题 " + i, "时间 " + i));
+ }
+ MarqueeFactory<RelativeLayout, ComplexItemEntity> marqueeFactory5 = new ComplexViewMF(this);
+ marqueeFactory5.setData(complexDatas);
marqueeView5.setAnimInAndOut(R.anim.top_in, R.anim.bottom_out);
marqueeView5.setMarqueeFactory(marqueeFactory5);
marqueeView5.startFlipping();

0 comments on commit 94db300

Please sign in to comment.