Click here to Skip to main content
15,868,420 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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.);
Posted

1 solution

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.
 
Share this answer
 
Comments
Alexander24 1-Feb-14 12:38pm    
What do you mean by location??? I tried R.id.display but it didn't work.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900