相关疑难解决方法(0)

自定义按钮有两个TextView

我正在尝试在一个按钮内使用两个带有不同字体的TextView自定义按钮.为此,我只是扩展了Button并在构造函数中编写了以下代码,

LayoutInflater layoutInflater = (LayoutInflater) context
        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = layoutInflater.inflate(R.layout.custom_button,
        (ViewGroup) findViewById(R.id.custom_button_view));

TextView firstTextView = (TextView) layout
        .findViewById(R.id.firstTextView);
TextView secondTextView = (TextView) layout
        .findViewById(R.id.secondTextView);
Run Code Online (Sandbox Code Playgroud)

在布局custom_button我已经放置了两个具有不同字体和文本的TextView,custom_button_view是该LinearLayout的ID,我得到的是一个没有文本的空按钮.

任何想法,谢谢.

android

6
推荐指数
1
解决办法
7859
查看次数

标签 统计

android ×1