• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

Android

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Friends help you move. Good friends help you move bodies. This tiny ad will help:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic