开发者

How to pass text from one Activity to Another with Same Characteristics?

Can any one tell me how to pass the value from one screen to its previous screen. Consider the case.i m having two screen first screen with one Textview and button and the second activity have one edittext and button.

If i click the first button then it has to move to second activity and here user has to type something in the textbox. If he press the button from the s开发者_如何学JAVAecond screen then the values from the textbox should move to the first activity and that should be displayed in the first activity textview.

This is passing Values from one activity to another

i want to pass the text with same FontStyle, Color and Size of the font.


Use the same style,color and size for first activity TextView and second Activity's EditTextView.

If you are done it with programming, then just pass the other parameters also with the intents, and set it in the first activity's TextView.

Like,

intent.putExtra("fontStyle","American Dream");
intent.putExtra("color","value");
intent.putExtra("size","value");

Use this in first activity to set TextView's properties.

String fontStyle = getIntent().getExtras().getString("fontStyle");
String fontColor = getIntent().getExtras().getString("color");
String fontSize  = getIntent().getExtras().getString("size");

  Typeface font2 = Typeface.createFromAsset(getApplicationContext().getAssets(),"fonts/"+fontStyle+".ttf"); 
  // here fontStyle is string which you passed from the second Activity 
  textView.setTypeface(font2);


Also, you can do this onClick

SecondButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            TextView text= (TextView) findViewById(R.id.textview);

                            text.settext(Edittext.getText());
            Intent intent= new Intent(form2.this, form1.class);
            startActivity(intent);
        }
    });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜