iconifiedtextview.java
来自「android文件系统」· Java 代码 · 共 40 行
JAVA
40 行
package com.mymobisoft.mobisoft.iconlist;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
public class IconifiedTextView extends LinearLayout {
private TextView textView;
private ImageView imageView;
public IconifiedTextView(Context context, IconifiedText iconifiedText) {
super(context);
this.setOrientation(HORIZONTAL);
imageView = new ImageView(context);
imageView.setImageDrawable(iconifiedText.getIcon());
imageView.setPadding(0, 2, 5, 0);
// 添加 Icon
addView(imageView, new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
textView = new TextView(context);
textView.setText(iconifiedText.getText());
// 在 Icon 之后添加文字
addView(textView, new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}// end IconifiedTextView
public void setIcon(Drawable drawable)
{
imageView.setImageDrawable(drawable);
}// end setIcon()
public void setText(String text)
{
textView.setText(text);
}// end setText()
}// end class IconifiedTextView
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?