i’m new to programming in Java and android… Here is my question, again not sure if the information I provide is sufficient.
What I’m trying to do is create a simple two activity app….
So i have the main activity and a user clicks a button and a new activity is launched that sets a new layout.
I’ve looked at the two following websites:
http://developer.android.com/guide/components/fragments.html
http://www.vogella.com/articles/Android/article.html#fragments_tutorial
Both very useful but when I tried to implement had issues.
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Button buttonLoadProfile = (Button) findViewById(R.id.buttonLoadProfile);
buttonLoadProfile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent profileIntent = new Intent();
profileIntent.setClass(getActivity(),LoadProfile.class);
// setContentView(R.layout.profile_layout);
}
});
}
The error I get is “The method getActivity() is undefined for the type new View.OnClickListener(){}”
Use
This will resolve the enclosing class from the inner.