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 trialAbdulaziz Alahmadi
2,623 Pointswhy it does not want to work ?
it does not auto complete anything and sometimes when the teacher have errors, i don't have them !! what happening ?
this a pic of my program http://s18.postimg.org/uc9idzsp5/error.png
Abdulaziz Alahmadi
2,623 Pointsyou mean this one:
package com.Azoz158.funfacts;
import android.app.Activity;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.TextView;
public class FunFactsActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fun_facts);
// declare our view variables and assign them the views from layout
Textview_factLable = findViewById(R.id.FactTextView);
Button showFactButton (Button) findViewById(R.id.showFactButton);
View.OnClickListener listener = new OnClickListener() {
ShowFactButton.setOnClickListener();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.fun_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();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
1 Answer
Steve Hunter
57,712 PointsYes.
For starters, if you change this bit:
// change this
Textview_factLable = findViewById(R.id.FactTextView);
// to this
Textview factLable = findViewById(R.id.FactTextView);
Next, orgainse your imports. I don't know the keys to do that - in Mac its Option & Return; hover your mouse over the red lines in View
and see what the auto-fix is. That'll sort that out.
A few more bits:
// change this line
Button showFactButton (Button) findViewById(R.id.showFactButton);
// change to
Button showFactButton = (Button) findViewById(R.id.showFactButton);
Next -
// change this line
ShowFactButton.setOnClickListener();
// to this
showFactButton.setOnClickListener();
Have a go at those changes and then let's see where you're at. e can make sure you get back on track with this project!
Steve.
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsCan you post your
FunFactsActivity
code, please, rather than a picture of it. There's a couple of things in there that need correcting and I think we can get it working from there.Steve.