按钮未显示单击

时间:2017-10-16 20:52:16

标签: android

我正在为我的应用实施共享选项。我构建了一切,功能方面也没有问题。我唯一的问题是当我按下"分享"纽扣。通常,单击按钮时,按钮会将背景颜色更改为稍暗。但是,我的共享按钮不是这样做的,我不知道为什么。这是其中之一:

<LinearLayout
    android:layout_width="75dp"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:id="@+id/text_share"
    android:layout_weight="1">

    <android.support.v7.widget.AppCompatImageView
         android:focusable="false"
         android:focusableInTouchMode="false"
         android:layout_width="65dp"
         android:layout_height="70dp"
         android:layout_marginTop="5dp"
         android:layout_gravity="center_horizontal"
         android:src="@drawable/icon_sms"
         android:scaleType="fitXY"
         android:background="@color/primaryDark" />

     <android.support.v7.widget.AppCompatTextView
         android:focusable="false"
         android:focusableInTouchMode="false"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_gravity="center_horizontal"
         android:text="SMS"
         android:textStyle="bold"
         android:textSize="14sp"
         android:textColor="#ffffff"/>
</LinearLayout>

我的JAVA读到:

View textShare = findViewById(R.id.text_share);
textShare.setOnClickListener(new View.OnClickListener(){
    @Override
    public void onClick(View view) {
        //share code here
    }
});

1 个答案:

答案 0 :(得分:1)

答案非常简单易行!

通过将tf_vect_final = CountVectorizer(max_df=0.90,min_df=5,stop_words=stop, ngram_range=(5,5),analyzer='word') tf_vect_final.fit(dfn['Not Written Comments_clean_stop'].tolist()) print("There are {} grams found".format(len(tf_vect_final.get_feature_names()))) tff = tf_vect_final.transform(dfn['Not Written Comments_clean_stop'].tolist()) tff = pd.DataFrame(tff.toarray(),columns=tf_vect_final.get_feature_names()) dfn.index.names=['PK'] tff.index.names=['PK'] dfn = dfn.reset_index() tff = tff.reset_index() dfn_final = dfn.merge(tff, on= 'PK') 添加到您的LinearLayout属性中,使LinearLayout可点击。

替代答案

您不需要使用android:clickable="true",您应该创建常规LinearLayout并使用Buttonandroid:drawableLeft在按钮中的文字之前添加图片,如果您要创建自定义按钮,则可以更改背景,文本颜色,文本大小和其他属性。如果您想使自定义样式成为全局样式,文件android:drawableStart将为您提供帮助。

相关问题