Not able to save LinearLayout values to xml file - android

Developing an android app here I am dynamically generating EditText and button like Call and Remove from row.xml file. adding these control to LinearLayout I implemented as I want but my problem is that I want to save the EditText values into xml file. so that next time I open this app the particular values gets populated from xml file.
Adding name and Mobile number to TextBox and click on "Add" button these values are dynamically added to LinearLayout. when I click on Add this values are stored into xml file and whenever next time I launch the app stored xml values are populated into LinearLayout.
this is my code
public class MainActivity : Activity
{
int count = 1;
EditText textIn, txtPhoneNo;
Button buttonAdd;
LinearLayout container;
EditText textOut;
System.Collections.ArrayList arrList = new System.Collections.ArrayList();
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
textIn = (EditText)FindViewById(Resource.Id.textin);
txtPhoneNo = (EditText)FindViewById(Resource.Id.txtPhoneNo);
buttonAdd = (Button)FindViewById(Resource.Id.add);
container = (LinearLayout)FindViewById(Resource.Id.container);
}
private void buttonAdd_Click(object sender, EventArgs e)
{
LayoutInflater layoutInflater = Application.Context.GetSystemService(Context.LayoutInflaterService) as LayoutInflater;
View addView = layoutInflater.Inflate(Resource.Layout.row, null);
textOut = (EditText)addView.FindViewById(Resource.Id.textout);
arrList.Add(txtPhoneNo.Text);
if (textIn.Text != "" && txtPhoneNo.Text != "")
{
textOut.SetText(textIn.Text + " : " + txtPhoneNo.Text, TextView.BufferType.Normal);
container.AddView(addView);
Button btnCall = (Button)addView.FindViewById(Resource.Id.btnCall);
btnCall.Click += BtnCall_Click;
Button buttonRemove = (Button)addView.FindViewById(Resource.Id.remove);
buttonRemove.Click += ButtonRemove_Click;
}
else
{
Toast.MakeText(this, "Field can not be blank.", ToastLength.Short).Show();
}
}
private void BtnCall_Click(object sender, EventArgs e)
{
var callDialog = new AlertDialog.Builder(this);
string strNo = After(textOut.Text,":");
callDialog.SetMessage("Call " + strNo + "?");
callDialog.SetNeutralButton("Call", delegate
{
var callIntent = new Intent(Intent.ActionCall);
callIntent.SetData(Android.Net.Uri.Parse("tel:" + strNo));
StartActivity(callIntent);
});
callDialog.SetNegativeButton("Cancel", delegate { });
// Show the alert dialog to the user and wait for response.
callDialog.Show();
}
}
}
Main.axml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity">
<EditText
android:id="#+id/textin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:hint="name" />
<EditText
android:id="#+id/txtPhoneNo"
android:layout_width="345.0dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:hint="Phone No." />
<Button
android:id="#+id/add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="Add" />
<LinearLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</LinearLayout>
row.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/remove"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="Remove"/>
<Button
android:id="#+id/btnCall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/remove"
android:text="Call"/>
<EditText
android:id="#+id/textout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#id/remove"/>
</RelativeLayout>

No you can't
you cannot store controls dynamically into your xml layout.
Either you add it manually into xml or you can create separate xml for control and then include it xml into your parent xml
<include
android:layout="id of your layout"
//height ... width
/>
In both ways, you have to create xml.
We are creating xml and inflate it in our java class. what you want to do is totally reverse of that.
Update
use shared preference
SharedPreference shared= context.getSharedPreferences("your preference name",
Context.MODE_PRIVATE);
String value = shared.getString("UserPhone","no data");
//set this value to your control

I think you need to refer SharedPreferences in android. This will serve your purpose.

Related

Retrieve data from SQLite and showing the data as radio buttons

I'm developing an android application which stores words given by the user in a SQLite database. And I want to retrieve those words as radio buttons so that the user can select only one word from the words list show in the textview.
And I want to create the xml file to fulfill that requirement.
Help me with this and thanks in advance.
*
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".EditPhrase">
<TextView
android:id="#+id/editText"
android:layout_width="355dp"
android:layout_height="71dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="28dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:text="#string/edit_phrases"
android:textColor="#000000"
android:textSize="30sp"
/>
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/editText">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RadioGroup
android:layout_width="400dp"
android:layout_height="wrap_content">
<TextView
android:id="#+id/phraseView"
android:layout_width="400dp"
android:layout_height="wrap_content"
android:autoLink="web"
android:lineSpacingExtra="#dimen/line_spacing"
android:padding="#dimen/padding_regular"
android:text="" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
*
P.S. - "phraseView" textview is used to show the retrieved data from sqlite database and it works and all the words are printed one by one.
Now I want to have a radio button in-front of every word so that the user can select only one word
*
public class EditPhrase extends AppCompatActivity {
TextView textView;
DatabaseHelper translateDB;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit_phrase);
textView = findViewById(R.id.phraseView);
translateDB = new DatabaseHelper(this);
showData();
}
public void showData(){
Cursor cursor = translateDB.retrieveData();
System.out.println("1");
if (cursor.getCount() == 0){
Toast.makeText(EditPhrase.this, "No data", Toast.LENGTH_LONG).show();
return;
}
StringBuffer buffer = new StringBuffer();
System.out.println("2");
while (cursor.moveToNext()) {
System.out.println("3");
buffer.append(" " + cursor.getString(0) + "\n");
}
textView.setText(buffer.toString());
}
}
*
Try putting the radio buttons inside a RecyclerView or ListView which is inside a RadioGroup

How to get value from dynamically created edit text in Android?

How to get value from dynamically created EditText in Android?
This is my dynamic view (XML file)
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/et_waypoint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/background"
android:hint="Way Points"
android:padding="10dp"
android:textSize="16sp" />
<Button
android:id="#+id/btn_waypoint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Find" />
</LinearLayout>
And I am using LayoutInflater because I want perfect Designed layout which is not accomplish by me via setLayoutParams so this is the reason I am using LayoutInflater.
And here is my code:
LayoutInflater l = getLayoutInflater();
final LinearLayout mainActivity = (LinearLayout) findViewById(R.id.dynamic);
final View view = l.inflate(R.layout.dynamic_layout_waypoints, null);
buttonWayPoints = (Button) view.findViewById(R.id.btn_waypoint);
editTextWayPoints = (EditText) view.findViewById(R.id.et_waypoint);
mainActivity.addView(editTextWayPoints);
I am new to Android. Most of people suggest this solution but it's not worked for me, the issue is when I implement this code my ADD NEW EDIT TEXT BUTTON not respond me.
This is how I am trying to get inserted value but it returns value of only last created edit text:
public Cursor getPerson(String Query) {
SQLiteDatabase db = this.getReadableDatabase();
Cursor c = db.rawQuery(Query, null);
return c;
}
sb is StringBuilder sb;, w is String w;
String queryWayPoints = "select * from route_table where trip_id = " + t;
Cursor s = myDb.getPerson(queryWayPoints);
int count3 = s.getCount();
for (int j = 0; j < count3; j++) {
s.moveToNext();
w = s.getString(s.getColumnIndex("waypoints"));
// se.append(w + "." + "00");
}
trip_name.setText(n);
trip_date.setText(d);
sb.append(w);
}
trip_route.setText(sb.toString());
Although, I didn't get what exactly your question is, still I'll try to help.
What exactly this code does is, on clicking the button on top an new layout(one that you wanted) will add to the activity screen at runtime, i.e an edittext with a button, and when you click on that button, A toast with the value of respective edittext will be shown. Hence solving the problem of getting the value of dynamically added edittext
MainActivity
public class MainActivity extends AppCompatActivity {
Button generateET;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final LinearLayout myLinearLay = (LinearLayout) findViewById(R.id.dynamic);
generateET = (Button) findViewById(R.id.generateBtn);
generateET.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
LayoutInflater l = getLayoutInflater();
final View viewToAdd = l.inflate(R.layout.to_add, null);
Button buttonWayPoints = (Button) viewToAdd.findViewById(R.id.btn_waypoint);
final EditText editTextWayPoints = (EditText) viewToAdd.findViewById(R.id.et_waypoint);
buttonWayPoints.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
if (editTextWayPoints.getText().toString() != null) {
Toast.makeText(MainActivity.this, editTextWayPoints.getText().toString(), Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(MainActivity.this, "No text found", Toast.LENGTH_SHORT).show();
}
}
});
myLinearLay.addView(viewToAdd);
}
});
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.techmahindra.stackques.MainActivity">
<Button
android:id="#+id/generateBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="add editText To layout" />
<ScrollView
android:layout_below="#+id/generateBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:id="#+id/dynamic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
></LinearLayout>
</ScrollView>
</RelativeLayout>
to_add.xml(layout which will be inflated at runtime)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/et_waypoint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Way Points"
android:padding="10dp"
android:textSize="16sp" />
<Button
android:id="#+id/btn_waypoint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Find" />
</LinearLayout>
There are some problems with your code. You're trying to add editTextWayPoints to mainActivity, but editTextWayPoints already has a parent, which is view. I think you should be adding view to mainActivity (mainActivity.addView(view)). Finally, to access the value of editTextWayPoints, you simply do editTextWayPoints.getText().toString();

How to add an EditText in a TextView?

I am trying to add an EditText within a TextView. My idea is to build a two activities, wherein in the first activity, fill in the blanks type of question will be entered in EditText and will be sent to second activity on button click and in second activity I want the text entered in the first activity to be displayed along with the EditText in the place of blank where it needs to answered.
My whole idea was to enter fill in the blank question with underscore at the place to be answered in the first activity and to display the question in the second activity by replacing the underscore with EditText.
first activity class code:
public class FirstActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_first);
}
public void onButtonClick(View view)
{
if (view.getId() == R.id.button)
{
EditText editText = (EditText) findViewById(R.id.editText);
String text = editText.getText().toString();
Intent intent = new Intent(this, Main2Activity.class);
intent.putExtra("mytext", text);
startActivity(intent);
}
}
}
First activity layout code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".FirstActivity">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:layout_marginTop="48dp"
android:id="#+id/editText"
android:hint="Enter here"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/editText"
android:layout_centerHorizontal="true"
android:layout_marginTop="100dp"
android:id="#+id/button"
android:onClick="onButtonClick" />
</RelativeLayout>
Second Activity Class:
public class SecondActivity extends AppCompatActivity {
TextView textView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
TextView textview1 = (TextView) findViewById(R.id.textView);
int positionX = textview1.getLeft();
int positionY = textview1.getRight();
EditText ed = new EditText(this);
ed.setEnabled(false);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) ed.getLayoutParams();
params.leftMargin = positionX;
params.topMargin = positionY;
params.width = 30;
ed.setLayoutParams(params);
textview1.setText(getIntent().getStringExtra("mytext"));
}
}
Second Activity Layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_main2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".SecondActivity">
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginStart="33dp"
android:layout_marginTop="47dp"
android:id="#+id/textView" />
</RelativeLayout>
You could split your text with your underscore characters, then, programmatically add TextViews and EditText.
Take a look at this.

Adapter dynamically created textview is not aligning properly

In my android application i am creating textview dynamically and each textview have onclick with respect to the type which have been send from webservice.
last text must be aligned to next line, below i have added my layout details
My adapter class
ArrayList<GroupTitleVo> titlelist = activitylist.get(position)
.getTitlelist();
LinearLayout sample_layout = new LinearLayout(_context);
sample_layout.setLayoutParams(new LinearLayout.LayoutParams(
0, 0));
sample_layout.setOrientation(LinearLayout.HORIZONTAL);
for (int i = 0; i < titlelist.size(); i++) {
if (titlelist.get(i).getType().equals("user")) {
TextView user_text = new TextView(_context);
user_text.setId(i);
user_text.setTextColor(Color.parseColor("#000000"));
user_text.setTextSize(12);
user_text.setTypeface(null, Typeface.BOLD);
user_text.setText(" "+titlelist.get(i).getName());
user_text.setTag(titlelist.get(i).getId()+"~"+titlelist.get(i).getName());
user_text.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
String id = (String) v.getTag();
Toast.makeText(_context, "user id" + id,
Toast.LENGTH_SHORT).show();
String[] name = id.split("~");
listener.userProfileredirect(name[0],name[1]);
}
});
holder.horizontaltext.addView(user_text);
} else if (titlelist.get(i).getType().equals("verb")) {
TextView verb_text = new TextView(_context);
verb_text.setId(i);
verb_text.setText(" "+titlelist.get(i).getName());
verb_text.setTextSize(10);
verb_text.setTag(titlelist.get(i).getId());
holder.horizontaltext.addView(verb_text);
} else {
TextView group_text = new TextView(_context);
group_text.setId(i);
group_text.setTextColor(Color.parseColor("#000000"));
group_text.setTextSize(14);
group_text.setTypeface(null, Typeface.BOLD);
group_text.setTag(titlelist.get(i).getId() + "~"
+ titlelist.get(i).getType());
group_text.setTextSize(12);
group_text.setText(" "+titlelist.get(i).getName());
group_text.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String id = (String) v.getTag();
Toast.makeText(_context, "Group ID" + id,
Toast.LENGTH_SHORT).show();
String idtype[] = id.split("~");
if (idtype.length > 1) {
listener.userGroupRedirect(idtype[1], idtype[0]);
}
}
});
holder.horizontaltext.addView(group_text);
}
}
And XML parent layout
<LinearLayout
android:id="#+id/textlinearlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/posted_person_img_view_id"
android:orientation="horizontal" >
</LinearLayout>
Kindly help me to align this textviews
You need to make nested layouts.
LinearLayout
You have to set horizontally LinearLayout, so you have all items in one horizontal line. You need to put into your existing LinearLayout your ImageView and create into it another LinearLayout set vertically to have two TextView items one below another.
Your view should look like this:
<?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">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_gallery"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="First text"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Second text text"/>
</LinearLayout>
</LinearLayout>
In existing code create another LinearLayout, set orientation of it as vertical and copy into it your two TextViews.
RelativeLayout
You need to declare a position of every item, just like in this example
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="#+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_gallery"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"/>
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="First text"
android:layout_above="#+id/textView2"
android:layout_toRightOf="#+id/image"/>
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Second text text"
android:layout_below="#+id/textView1"
android:layout_toRightOf="#+id/image"/>
</RelativeLayout>
I used here XML files, because I think it might be more clear to see what attributes and views you would need to use.
EDIT: To create RelativeLayout programmaticaly read:
How to lay out Views in RelativeLayout programmatically?
Hope it help.

How do I make another block of text?

I understand how to display some text with the user input, but what I'm confused about is how to add a completely new block of text under the one I have right now (I want to put a new block of text because I want the size of the text to be different). Right now, I display "Welcome [user input]!"
In my activity file I have:
public class DisplayMessageActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get the message from the intent
Intent intent = getIntent();
String message = " Welcome " + intent.getStringExtra(MainActivity.EXTRA_MESSAGE) + "!";
// Create the text view
TextView textView = new TextView(this);
textView.setTextSize(25);
textView.setText(message);
// Set the text view as the activity layout
setContentView(textView);
}
And in my fragment.xml file, I have:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context="com.example.myfirstapp.DisplayMessageActivity$PlaceholderFragment"
android:gravity="center_horizontal"
android:orientation="vertical"
android:weightSum="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
<TextView
android:layout_width="wrap_content"
android:text="TEST"
android:layout_height="wrap_content" />
</LinearLayout>
With some help from the feedback I got from other users, I added android:text="TEST" too the second "TextView". And I also added the android:orientation="vertical" to LinearLayout. But the "TEST" still doesn't show up when I run the app! Thanks in advance.
You are not associating your layout to your Activity. Instead, you are adding a TextView on runtime, that is created on runtime. That's why only one TextView appears. You have to use setContentView(R.layout.mylayout); instead of setContentView(textView);, so your Activity fetches your layout.
Edit: In your layout, add ids to your TextViews, so you can access them from your Activity code, like this:
<TextView
android:id="#+id/myFirstTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="TEST1" />
<TextView
android:id="#+id/mySecondTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="TEST2" />
Then on your Activity, inside onCreate():
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.my_layout);
// Get the message from the intent
Intent intent = getIntent();
String message = " Welcome " + intent.getStringExtra(MainActivity.EXTRA_MESSAGE) + "!";
TextView textView1 = (TextView) findViewById(R.id.myFirstTextView);
TextView textView2 = (TextView) findViewById(R.id.mySecondTextView);
textView1.setTextSize(25);
textView1.setText(message);
}
Assuming fragment.xml is in the res/layout folder
setContentView(R.layout.fragment);
instead of
setContentView(textView);

Categories

Resources