Skip to content

Commit

Permalink
修复commontextview点击事件无效的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lygttpod committed Dec 22, 2016
1 parent 2a3e5db commit 348a960
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 5 deletions.
14 changes: 14 additions & 0 deletions app/src/main/res/layout/common_textview_layout.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ctv="http://schemas.android.com/apk/res-auto"
xmlns:wave="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
Expand Down Expand Up @@ -121,7 +122,20 @@
ctv:cShowDividerLineType="both"
ctv:cUseRipple="true" />

<com.allen.library.CommonTextView
android:layout_width="match_parent"
android:layout_height="50dp"
ctv:cCenterTextColor="@android:color/darker_gray"
ctv:cCenterTextString="请选择客户性别:"
ctv:cCenterTextViewGravity="left_center"
ctv:cLeftTextString="客户性别"
ctv:cLeftViewPaddingLeft="20dp"
ctv:cRightIconResForDrawableRight="@drawable/arrow_right_red"
ctv:cRightTextString=""
ctv:cUseRipple="true" />
</LinearLayout>


</ScrollView>


Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.android.tools.build:gradle:2.2.3'
//classpath 'com.novoda:bintray-release:0.3.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
defaultConfig {
minSdkVersion 11
targetSdkVersion 24
versionCode 107
versionName "1.0.7"
versionCode 108
versionName "1.0.8"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Expand Down
28 changes: 26 additions & 2 deletions library/src/main/java/com/allen/library/CommonTextView.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,13 @@ private void init() {
// if (mRight_IV_drawable!=null){
// initRightImageView();
// }
if (mLeftTextString != null) {
if (mLeftTextString != null||mLeft_drawableLeft!=null||mLeft_drawableRight!=null) {
initLeftText();
}
if (mCenterTextString != null) {
initCenterText();
}
if (mRightTextString != null) {
if (mRightTextString != null||mRight_drawableLeft!=null||mRight_drawableRight!=null) {
initRightText();
}

Expand Down Expand Up @@ -487,6 +487,14 @@ private void initLeftText() {
leftTextView.setText(mLeftTextString);
leftTextView.setLineSpacing(mLeftTextViewLineSpacingExtra, 1.0f);
setTextViewGravity(leftTextView, mLeftTextViewGravity);
leftTextView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (onCommonTextViewClickListener!=null){
onCommonTextViewClickListener.onLeftViewClick();
}
}
});
}

setDrawable(leftTextView, mLeft_drawableLeft, mLeft_drawableTop, mLeft_drawableRight, mLeft_drawableBottom, mLeftIconDrawablePadding);
Expand Down Expand Up @@ -550,6 +558,14 @@ private void initCenterText() {
centerTextView.setText(mCenterTextString);
centerTextView.setLineSpacing(mCenterTextViewLineSpacingExtra, 1.0f);
setTextViewGravity(centerTextView, mCenterTextViewGravity);
centerTextView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (onCommonTextViewClickListener!=null){
onCommonTextViewClickListener.onCenterViewClick();
}
}
});

}
setDrawable(centerTextView, mCenter_drawableLeft, mCenter_drawableTop, mCenter_drawableRight, mCenter_drawableBottom, mCenterIconDrawablePadding);
Expand Down Expand Up @@ -615,6 +631,14 @@ private void initRightText() {
// rightTextView.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
rightTextView.setLineSpacing(mRightTextViewLineSpacingExtra, 1.0f);
setTextViewGravity(rightTextView, mRightTextViewGravity);
rightTextView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (onCommonTextViewClickListener!=null){
onCommonTextViewClickListener.onRightViewClick();
}
}
});

}
setDrawable(rightTextView, mRight_drawableLeft, mRight_drawableTop, mRight_drawableRight, mRight_drawableBottom, mRightIconDrawablePadding);
Expand Down

0 comments on commit 348a960

Please sign in to comment.