I’m trying to create a tablayout where have two tabs for now. One tab has a button,editText and another has a ediText. When I press the button I need to read the text from the another tab and put it in current edittext. But when I try this, I’ve been getting a force close error.For testing I tried putting the content of the editText to the button name.
package android.work;
import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TabHost;
import android.widget.TextView;
public class tabcontent1 extends Activity
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//TextView txt=new TextView(this);
//txt.setText("Tab1");
setContentView(R.layout.tab1content);
final Button but=(Button)findViewById(R.id.button1);
but.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
EditText ed=(EditText)findViewById(R.id.editText2);
String str=ed.getText().toString();
EditText ed1=(EditText)findViewById(R.id.editText1);
but.setText(str);
}
});
}
}
;
Check if you’re not getting nullpointerexception…