第一行代码第三章源码整理

1:UIWidgettest

package com.example.uiwidgettest;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Toast;

public class MainActivity extends Activity implements OnClickListener {

    private Button button;

    private EditText editText;

    private ImageView imageView;

    private ProgressBar progressBar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        button = (Button) findViewById(R.id.button);
        editText = (EditText) findViewById(R.id.edit_text);
        imageView  = (ImageView) findViewById(R.id.image_view);
        progressBar = (ProgressBar) findViewById(R.id.progress_bar);
        button.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.button:
        //¸´ÖÆÎı¾
        //  String inputText=editText.getText().toString();
        //  Toast.makeText(MainActivity.this, inputText, Toast.LENGTH_LONG).show();
        //±ä»»Í¼Æ¬
        //  imageView.setImageResource(R.drawable.jelly_bean);
        // ½ø¶ÈÌõ
        //  int progress =progressBar.getProgress();
        //  progress=progress + 10;
        //  progressBar.setProgress(progress);
        //½ø¶ÈÌõÏûʧ
            if (progressBar.getVisibility()==View.GONE){
                progressBar.setVisibility(View.VISIBLE);
                }
            else{
                progressBar.setVisibility(View.GONE);
            }
            break;
        default:
            break;
        }
    }

}

你可能感兴趣的:(android)