Skip to content

Commit 689b444

Browse files
committed
修复bug
1 parent 30d9400 commit 689b444

File tree

4 files changed

+165
-118
lines changed

4 files changed

+165
-118
lines changed

app/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ android {
2020
}
2121

2222
dependencies {
23-
compile fileTree(dir: 'libs', include: ['*.jar'])
23+
compile fileTree(include: ['*.jar'], dir: 'libs')
2424
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
2525
exclude group: 'com.android.support', module: 'support-annotations'
2626
})
2727
compile 'com.android.support:appcompat-v7:26.+'
2828
compile 'com.android.support.constraint:constraint-layout:1.0.2'
2929
testCompile 'junit:junit:4.12'
3030
compile project(':library')
31+
compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
3132
}
Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
11
package com.study.xuan.easytextview;
22

33
import android.graphics.Color;
4-
import android.support.v7.app.AppCompatActivity;
54
import android.os.Bundle;
5+
import android.support.v7.app.AppCompatActivity;
6+
import android.support.v7.widget.LinearLayoutManager;
7+
import android.support.v7.widget.RecyclerView;
8+
import android.view.LayoutInflater;
69
import android.view.View;
10+
import android.view.ViewGroup;
711

812
import com.study.xuan.library.widget.EasyTextView;
913

14+
import java.util.ArrayList;
15+
import java.util.List;
16+
1017
public class MainActivity extends AppCompatActivity {
1118
private EasyTextView textView;
19+
private int[] color = new int[]{
20+
Color.parseColor("#ff2193"),
21+
Color.parseColor("#192193"),
22+
Color.parseColor("#dcdcdc")
23+
};
24+
1225
@Override
1326
protected void onCreate(Bundle savedInstanceState) {
1427
super.onCreate(savedInstanceState);
@@ -17,11 +30,46 @@ protected void onCreate(Bundle savedInstanceState) {
1730
textView.setOnClickListener(new View.OnClickListener() {
1831
@Override
1932
public void onClick(View v) {
20-
textView.setTextLeftColor(Color.parseColor("#ff9374"));
33+
textView.setTextLeftColor(Color.GREEN);
2134
textView.setTextLeftSize(24);
2235
//textView.setTextRightSize(24);
2336

2437
}
2538
});
39+
final List<String> data = new ArrayList();
40+
for (int i = 0; i < 100; i++) {
41+
data.add("第" + i + "个");
42+
}
43+
RecyclerView rcy = (RecyclerView) findViewById(R.id.rcy);
44+
rcy.setLayoutManager(new LinearLayoutManager(this));
45+
rcy.setAdapter(new RecyclerView.Adapter<ViewHolder>() {
46+
@Override
47+
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
48+
return new ViewHolder(LayoutInflater.from(MainActivity.this).inflate(R.layout
49+
.item_layout, parent, false));
50+
}
51+
52+
@Override
53+
public void onBindViewHolder(ViewHolder holder, int position) {
54+
holder.tv.setText(data.get(position));
55+
holder.tv.setIconColor(color[position % 3]);
56+
}
57+
58+
@Override
59+
public int getItemCount() {
60+
return data.size();
61+
}
62+
});
63+
2664
}
65+
66+
class ViewHolder extends RecyclerView.ViewHolder {
67+
EasyTextView tv;
68+
69+
public ViewHolder(View root) {
70+
super(root);
71+
tv = root.findViewById(R.id.easyText);
72+
}
73+
}
74+
2775
}

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,21 @@
99
>
1010

1111
<com.study.xuan.library.widget.EasyTextView
12-
android:id="@+id/easyText"
13-
style="@style/style_feed_list_user_state"
1412
android:layout_width="wrap_content"
1513
android:layout_height="wrap_content"
14+
app:textRight="@string/icon_font_home"
1615
android:text="@string/icon_font_home"
17-
app:textRight="99.9万"
18-
app:textPadding="12dp"
19-
android:clickable="true"
20-
app:textRightColor="@color/selector_feed_user_state_color"
21-
app:textLeftColor="@color/selector_feed_user_state_color2"
22-
app:iconColor="@color/selector_feed_user_state_color3"
23-
app:textLeft="左边的值"
24-
android:gravity="center_vertical"
25-
android:visibility="visible"
16+
app:textLeft="左边的"
17+
android:textSize="10dp"
18+
app:textPadding="20dp"
19+
app:textLeftSize="30dp"
20+
/>
21+
22+
<android.support.v7.widget.RecyclerView
23+
android:id="@+id/rcy"
24+
android:layout_width="match_parent"
25+
android:layout_height="match_parent"
26+
android:visibility="gone"
2627
/>
2728

2829
</LinearLayout>

0 commit comments

Comments
 (0)