Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Self-Destructing Message Android App Relating Users in Parse.com Adding the Edit Friends Screen

Code generated looks different than the video code generated.

The code generated by my eclipse looks very different than the one in the video (about the 5:05 mark). The code generated by my eclipse is pasted below. Is this something that should concern me? Should i change the code to match the videos or can I leave as is?

import android.app.Activity; import android.app.ActionBar; import android.app.Fragment; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.os.Build;

public class EditFriendsActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_edit_friends);

    if (savedInstanceState == null) {
        getFragmentManager().beginTransaction()
                .add(R.id.container, new PlaceholderFragment()).commit();
    }
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.edit_friends, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}

/**
 * A placeholder fragment containing a simple view.
 */
public static class PlaceholderFragment extends Fragment {

    public PlaceholderFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_edit_friends,
                container, false);
        return rootView;
    }
}

}

3 Answers

You should leave it as is unless you want to take away or change the action bar. This is the normal code generated while creating an activity so there's no need to worry!

If there are any problems I am open to answer them :)

Lincoln Daniel
Lincoln Daniel
430 Points

The code is completely different than what we were instructed to do in the EditFriendsActivity, is there a reason for this?

Hi Daniel, I think you are using different version of android SDK. If you want to use exact the code you can import the it to external libraries. Project on video is using support-v4-19.1.0.jar.

To make it in simplest possible way you can import the project downloaded from this lesson to your android studio. Important multiple part of the code in 22 version will look differently but I think that for purpose of supporting Android ver 4.0 and higher this library support-v4-19.1.0.jar is commonly used - it supports many features and themes like holo etc.

In the latest version to be able to accommodate the same functions you will need to use code differently especially for creation the tabs.

Cheers, Hubert