What should i learn for selecting element from XML file in java android devlopement. | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

What should i learn for selecting element from XML file in java android devlopement.

20th May 2020, 10:00 PM
Hamza Khan
Hamza Khan - avatar
3 Antworten
+ 1
ID of the element in the xml file. In the java file, access this element by id.
26th May 2020, 5:24 AM
Evseev Anton
Evseev Anton - avatar
+ 1
Xml file: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <TextView android:id="@+id/tvOut" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_marginBottom="50dp" android:text="TextView"> </TextView> </LinearLayout>
26th May 2020, 6:20 AM
Evseev Anton
Evseev Anton - avatar
+ 1
Java class file: public class MainActivity extends Activity { TextView tvOut; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); tvOut = (TextView) findViewById(R.id.tvOut); tvOut. setText("New some text"); } }
26th May 2020, 6:23 AM
Evseev Anton
Evseev Anton - avatar