[英]A Simple Misunderstanding: How can I incorporate java class on Android
這也許是其中最簡單的問題,但請為我體諒。
我正在研究一些有關如何在EditText中包裝文本的教程,我認為這些鏈接會對我有很大幫助。
現在我的問題是,如何合並該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"
/>
先生,這是行不通的。 我不知道那是因為代碼
希望您能理解:
首先:
private AutoResizeTextView autoResizeTextView;// instantiate
您在那里沒有實例化任何東西。 要創建對象,必須調用構造函數。
//and on my textview
txtCalc.setTextSize(autoResizeTextView);
看起來您的txtCalc
應該是AutoResizeTextView
而不是TextView
。 不要嘗試這樣 :
txtCalc = autoResizeTextView;
而是將XML文件(布局)中的視圖類型從<TextView />
更改為<yourPackageName.AutoResizeTextView></yourPackageName.AutoResizeTextView>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.