Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Android

 
shanmugi try
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String result;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sec);
et1 = (EditText) this.findViewById(R.id.editText1);
t1 = (TextView) this.findViewById(R.id.textView1);
t2 = (TextView) this.findViewById(R.id.textView2);
b1 = (Button) this.findViewById(R.id.button1);
b2 = (Button) this.findViewById(R.id.button2);
b1.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
t2.setText(et1.getText());
result = et1.getText().toString();

}
});
b2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(v.getContext(),ThirdActivity.class);
startActivity(i);
}
});
}
public String value(){
return result;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

public class Text extends PagerAdapter{

Context context;
SecondActivity s = new SecondActivity();
private String[] textViewer = new String[]{
s.value(),
"Hai"

};
public ImageAdapter(Context context){
this.context= context;
}

@Override
public int getCount() {
return textViewer.length;
}

@Override
public boolean isViewFromObject(View view, Object object) {
return view==((TextView)object);
}
public Object instantiateItem(ViewGroup container, int position) {
TextView textView = new TextView(context);
textView.setText(textViewer[position]);
((ViewPager) container).addView(textView, 0);
return textView;
}

@Override
public void destroyItem(ViewGroup container, int position, Object object) {
((ViewPager) container).removeView((TextView) object);
}

}

I want the edit text value to be added in the View Pager.It is returning null value.Actual requirement is i want to pass the edit text value to a class which extends PagerAdapter
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Shanmugi,

Welcome to the Ranch! When posting code, please UseCodeTags (<- click that link). It will make it a lot easier to read. I also removed the duplicate post.

I tried looking at your code and it is just not readable in the state it is in now, and the question isn't very clear either. Could you re-post the code you are having trouble with (just the parts with the issue - and don't forget to UseCodeTags ;) )? Then restate the problem a different way?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic