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 Making a Button Do Something

Eleni Minadaki
Eleni Minadaki
3,687 Points

App isn't installed

After run the application,there is a warning app isn't installed and Fun_Facts has stopped,i think that have delete and write rewrite something wrong in my code. Here is the file layout FunFactsActivity.java package com.teamtreehouse.funfacts;

import android.content.DialogInterface; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.widget.Button; import android.widget.TextView; import android.view.View;

public class FunFactsActivity extends ActionBarActivity {

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

    //Declare our vew variables and assign the Views from the layout file.
   TextView factLabel = (TextView) findViewById(R.id.fun_facts);
   Button showFactButton=(Button) findViewById(R.id.ShowFactButton);
    View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
          //The button was clicked, so update the fact label with a new fact

        }
    };
    showFactButton.setOnClickListener(listener);
}


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

} ans here the file layout activity_fun_facts.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".FunFactsActivity" android:id="@+id/fun_facts" android:background="#ff51b46d">

<TextView android:text="Did you know?" android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAllCaps="false"
    android:textSize="24sp"
    android:textColor="#80ffffff" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Eleni is happy every day!"
    android:id="@+id/FactsTextView"
    android:layout_centerVertical="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:textSize="24sp"
    android:textColor="@android:color/white" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Show Another Fun Fact"
    android:id="@+id/ShowFactButton"
    android:layout_alignParentBottom="true"
    android:layout_alignRight="@+id/FactsTextView"
    android:layout_alignEnd="@+id/FactsTextView"
    android:background="@android:color/white" />

</RelativeLayout>

Thanks for any help!

Hello,

Could you post the full output from the error? There might be a bit of a hint as to where in your code there is a problem in the output.