[source code] Android Development Tutorial - 18 & 19

+6 Bucky Roberts · December 23, 2014
package com.thenewboston.smartbutton;

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

public class MainActivity extends ActionBarActivity {

    protected void onCreate(Bundle savedInstanceState) {

        Button buckysButton = (Button)findViewById(R.id.buckysButton);

                new Button.OnClickListener(){
                    public void onClick(View v){
                        TextView buckysText = (TextView)findViewById(R.id.buckysText);
                        buckysText.setText("Good job Hoss!");

    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;

    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);

Post a Reply


Oldest  Newest  Rating
+1 Troy Jones · January 9, 2015
It's probably because that import hasn't been used yet.  Just my guess.  I think it's an Android Studio thing.
0 Arthur Zinatulin · January 5, 2015
Hey there! when I import new classes like: 
 import android.view.View;
 right after i put "  ;  " at the end, the line of code disappears.. Restart didn't help, even copy/paste from here didn't work , it just goes back to  it's original.. any ideas?
0 servet portakal · January 5, 2015
I'm by no means the go-to person, but one thing that comes to my mind is "code folding".  Can you check that? I guess if you click on import, it should extend the list, and show every "import" code.
0 Arthur Zinatulin · January 9, 2015
Thanks, but no, I only see classes created by default. I've tried to restart app and check if they will appear, but no, i extend the list and don't see them. 
0 Arthur Zinatulin · January 25, 2015
You are right Troy Jones, it starts to show those classes when i use them in coding. And I think they are being imported by themselves in the process of coding, it isn't necessary to do it manually  
  • 1

Java / Android Development


Very popular language used to create desktop applications, website applets, and Android apps.

Bucky Roberts Administrator