Pass line from operation to layout?

How to transfer a string from an operation to a layout? I can transfer arrays from an operation to a layout with the following activity code

ListView remedyList = (ListView) findViewById(R.id.ListView_Symptom); String remedyArray[] = new String[30]; ArrayAdapter<String> adapt = new ArrayAdapter<String>(this, R.layout.menu_item, remedyArray); remedyList.setAdapter(adapt); 

Is there an easier way to just pass a single row instead of any array of strings, from action to layout?

+4
source share
1 answer

if you are thinking of passing values ​​to a layout, you want these values ​​to appear in a layout element, such as Textview.

Suppose you have a TextView inside your layout.

 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#FFFFFF" > <TextView android:id="@+id/myTextView" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout> 

then you can set the string value in TextView

 String myText = "James"; TextView myTextView= (TextView) findViewById(R.id.myTextView); myTextView.setText(myText); 
+5
source

All Articles