I have defined a textview in my xml layout. Now when I want to call this textview inside my activity Java file, I don’t know how to do that. Can you please tell me how to do that? Thanx in advance.
Here is my xml layout:
<?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="vertical" >
<TextView
android:id="@+id/bubble_sort"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="left"
android:text=
"hello welome to your first c++ code."/>
</LinearLayout>
This is my Java file:
package com.example.cprograms;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class Bubble_sort extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
TextView tv = (TextView) findViewById(R.id.bubble_sort);
}
}
Add these lines
and
…..