创建一个计算器 [英] creating a calculator
问题描述
您好我有一个非常快速的问题。在下面的代码中Java没有导入TextView id,我真的不明白为什么。有人可以帮帮我吗?顺便说一下,我对android编程很新。
< textview>
android:id =@ + id / display
android:layout_width =wrap_removed
android:layout_height =wrap_removed
android:layout_alignParentTop =true
android:layout_centerHorizontal =true
android:layout_marginTop =23dp
android:fontFamily =sans-serif-thin
android:text =CV你的全部是:
android:textColor =#ffffff
android:textSize =25dp
android:textStyle =italic
/>
TextView display =(TextView )findViewById(android.R.id。);
Hello I have a very quick question. In the code below Java doesn't import the TextView id, I don't really understand why. Can someone help me out please?? By the way I'm very new with android programing.
<textview>
android:id="@+id/display"
android:layout_width="wrap_removed"
android:layout_height="wrap_removed"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="23dp"
android:fontFamily="sans-serif-thin"
android:text="CV YOUR TOTAL IS: "
android:textColor="#ffffff"
android:textSize="25dp"
android:textStyle="italic"
/>
TextView display=(TextView) findViewById(android.R.id.);
推荐答案
当我试图获取Android中某种UI元素的引用时,我必须使用R .id.Locattion其中location是控件的名称。例如:
< edittext>
android:id = @ + id / location
android:layout_width =match_parent
android:layout_height =wrap_content
android:layout_alignParentLeft =true
android:hint =@ string / location_string
android:inputType =textPostalAddress/>
找到这个代码:
final EditText addrText =(EditText)findViewById( R.id.location );
在您的代码中,您使用的是 android.R.id。 - 这应该是 R.id.display - 显示是您想要获得的控件的名称。
希望这有帮助。
When I am trying to get a reference to some sort of UI element in Android I have to use "R.id.Locattion" where location is the name of the controls. For example:
<edittext>
android:id="@+id/location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:hint="@string/location_string"
android:inputType="textPostalAddress" />
Is found with this code:
final EditText addrText = (EditText) findViewById(R.id.location);
In your code you are using "android.R.id." - this should probably be "R.id.display" - with "display" being the name of the control that you want to get.
Hope this helps.
这篇关于创建一个计算器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!