0

这可能是其中最简单的问题,但请体谅我。

我正在研究一些关于如何在 EditText 中包装文本的教程,我认为这些链接会对我有很大帮助。

StackOverFlow 答案 1

StackOverFlow 答案 2

现在我的问题是,我怎样才能合并那个 java 类。如您所见,我仍然是一名学生,在这些扩展方面我几乎没有经验。我尝试过使用实例化(我更倾向于使用 vb.net),这是我的代码

private AutoResizeTextView autoResizeTextView;// instantiate

//and on my textview
txtCalc.setTextSize(autoResizeTextView);

它不工作。你能帮我解决我的声明,因为我正在为我的学校项目创建一个计算器吗?

非常感谢您的时间和精力

编辑 我不知道我是否理解正确,但这就是我在布局上所做的

    <com.bracks.androidtest.AutoResizeTextView
    android:id="@+id/screen"
    android:layout_width="285dp"
    android:layout_height="54dp"
    android:layout_gravity="center"
    android:layout_marginTop="5dp"
    android:background="@drawable/box_border"
    android:clickable="false"
    android:enabled="false"
    android:gravity="center"
    android:longClickable="false"
    android:textColor="#333333"
    android:textSize="30dp" 
    />

先生,它不工作。我不知道那是不是因为代码

4

1 回答 1

1

希望你能明白:

首先:

private AutoResizeTextView autoResizeTextView;// instantiate

你没有在那里实例化任何东西。要创建对象,您必须调用构造函数。

//and on my textview
txtCalc.setTextSize(autoResizeTextView);

看起来你txtCalc应该AutoResizeTextView代替TextView. 不要尝试这个

txtCalc = autoResizeTextView;

而是将 XML 文件(布局)中的视图类型从<TextView />更改为<yourPackageName.AutoResizeTextView></yourPackageName.AutoResizeTextView>

于 2012-08-31T06:54:50.503 回答