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 Simple Android App (2014) Basic Android Programming Introduction to Methods and Classes

my java file android studio created is different than yours, and my xml file created 2 xml files instead of one

i have been following along exactly and my files that android studio created are different! It created the following 2 xml files... instead of one... and it put the stuff we are working on in the content one, not the activity:

activity_fun_facts.xml
content_fun_facts.xml

and my java file is different, Please not, I used the exact same setting as in the videos, I even wiped everything clean, and redid it all thinking I did something wrong. Wondering if android studio update had altered how stuff works since this video was made. If so , this is very bad! This is exactly why I payed 25$ to be taught this stuff, the books I keep buying never match and are unfollowable due to updates!

here is contents of my java file.

public class FunFactsActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fun_facts);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.funfacts, 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();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

}

Aditya Pore
Aditya Pore
1,453 Points

You probably installed Android SDK 6.0 which comes with CoordinatorLayout and RelativeLayout. CoordinatorLayout is β€œsuper-powered” FrameLayout used to coordinate dependencies between child views. You shall find actual content in content_fun_facts.xml. Hope this helps.

1 Answer

Ah that explains it! Thank you, I think I will remove 6.0 so all matches.