how do i call methods from another class in android?
Posted
by
Phani Gargey
on Stack Overflow
See other posts from Stack Overflow
or by Phani Gargey
Published on 2012-05-30T05:17:05Z
Indexed on
2012/06/01
4:41 UTC
Read the original article
Hit count: 152
android
I have two classes in question. Both extend Activity.
Class A
public void displayinfo()
{
setContentView(R.layout.dynamicinfo);
//Add some buttons dynamically here
//do some processing
// move on to Class B
}
In Class B: I want to go back to Class A state in UI if BACK button is pressed.
Class B
//Register a listener for this button
Backbutton.setOnClickListener(new OnClickListener()
{
public void onClick(View arg0)
{
Log.i("setOnClickListener", "Pressed Back Button ");
Toast.makeText(mycontext, "Pressed Back Button", Toast.LENGTH_SHORT).show();
//HERE I want to go back class's function in UI as well as restoring the sttae for that screen.
}
how do I do that? I looked around some questions. they did not answer clearly what I am looking for.hence the posting.
thanks.I think I was adding my own Back button on the Layout I created in the Class B's UI Screen --not using the regular "Back" button on the key board. May be that was the problem.
© Stack Overflow or respective owner