Android Open Source - musetoolkit Copy Of Main Activity






From Project

Back to project page musetoolkit.

License

The source code is released under:

GNU General Public License

If you think the Android project musetoolkit listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.github.musetoolkit;
//from  www.j ava 2  s  . c o m
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
//????TextView????

import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.KeyEvent;
import android.view.Window;
import android.widget.Toast;    //???????????Toast?????????

public class CopyOfMainActivity extends Activity implements OnClickListener { 
  /** Called when the activity is first created. */
  //??????????????????????
  public static void updateFullscreenStatus(Activity activity, Boolean bUseFullscreen){
  //?????
    if(bUseFullscreen){
      activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
      activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    }
    //???????????????????????
    else{
      activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
      activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }
    }

       private GridView mGridView;   //MyGridView
        //??????
       private int[] imageRes = { R.drawable.png01, R.drawable.png02,
       R.drawable.png03, R.drawable.png04, R.drawable.png05, R.drawable.png06,
       R.drawable.png07, R.drawable.png08, R.drawable.png09, R.drawable.png10,
       R.drawable.png11, R.drawable.png12 };
       //??????
       private String[] itemName = { "???", "???", "???", "???", "????", "??????", "?????",
       "????", "??????", "????", "??", "??" };

      @Override
      public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                this.requestWindowFeature(Window.FEATURE_NO_TITLE); // ??Activity??????
//                this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // ???????
                setContentView(R.layout.main);
 
                mGridView = (GridView) findViewById(R.id.MyGridView);
                List<HashMap<String, Object>> data = new ArrayList<HashMap<String, Object>>();
                int length = itemName.length;
                for (int i = 0; i < length; i++) {
                        HashMap<String, Object> map = new HashMap<String, Object>();
                        map.put("ItemImageView", imageRes[i]);
                        map.put("ItemTextView", itemName[i]);
                        data.add(map);
                }
                //?itme.xml??????
                SimpleAdapter simpleAdapter = new SimpleAdapter(CopyOfMainActivity.this,
                data, R.layout.item, new String[] { "ItemImageView","ItemTextView" }, new int[] { R.id.ItemImageView,R.id.ItemTextView });
                mGridView.setAdapter(simpleAdapter);
                //?mGridView???????????
                mGridView.setOnItemClickListener(new GridViewItemOnClick());
      }
      //???????????
      public class GridViewItemOnClick implements OnItemClickListener {
      @Override
      public void onItemClick(AdapterView<?> arg0, View view, int position,long arg3) {
//             Toast.makeText(getApplicationContext(), position + "",
//             Toast.LENGTH_SHORT).show();
        
        /* ?????????GridView?????????
         * ????Intent?????????
         * ??????????????
         */        
             Intent intent = new Intent();
             switch(position){
             case 0:
                 Toast.makeText(getApplicationContext(), "???",
                         Toast.LENGTH_SHORT).show();    
               intent.setClassName( "com.github.musetoolkit",
                             "com.github.musetoolkit.Sine" );
                  startActivity(intent);
                   break;
             case 1:
                 Toast.makeText(getApplicationContext(), "???",
                         Toast.LENGTH_SHORT).show();  
               intent.setClassName( "com.github.musetoolkit",
                             "com.github.musetoolkit.Triangle" );
                  startActivity(intent);
                   break;
             case 2:
                 Toast.makeText(getApplicationContext(), "???",
                         Toast.LENGTH_SHORT).show();  
               intent.setClassName( "com.github.musetoolkit",
                             "com.github.musetoolkit.Sawtooth" );
                  startActivity(intent);                          
                   break;
             case 3:
                 Toast.makeText(getApplicationContext(), "???",
                         Toast.LENGTH_SHORT).show();  
               intent.setClassName( "com.github.musetoolkit",
                             "com.github.musetoolkit.Wnoise" );
                  startActivity(intent);                          
                   break;
             case 4:
                 Toast.makeText(getApplicationContext(), "????",
                         Toast.LENGTH_SHORT).show();  
               intent.setClassName( "com.github.musetoolkit",
                             "com.github.musetoolkit.Pnoise" );
                  startActivity(intent);                          
                   break; 
             case 5:
                 Toast.makeText(getApplicationContext(), "??????",
                         Toast.LENGTH_SHORT).show();  
               intent.setClassName( "com.github.musetoolkit",
                             "com.github.musetoolkit.Sweep" );
                  startActivity(intent);                          
                   break;  
             case 6:
                 Toast.makeText(getApplicationContext(), "???",
                         Toast.LENGTH_SHORT).show();  
               intent.setClassName( "com.github.musetoolkit",
                             "com.github.musetoolkit.Spl" );
                  startActivity(intent);                          
                   break;                   
             case 7:
                 Toast.makeText(getApplicationContext(), "????",
                         Toast.LENGTH_SHORT).show();  
               intent.setClassName( "com.github.musetoolkit",
                             "com.github.musetoolkit.Test" );
                  startActivity(intent);                          
                   break;                   
             case 8:
                 Toast.makeText(getApplicationContext(), "??????",
                         Toast.LENGTH_SHORT).show();  
               intent.setClassName( "com.github.musetoolkit",
                             "com.github.musetoolkit.Piano" );
                  startActivity(intent);                          
                   break;                   
             case 9:
                 Toast.makeText(getApplicationContext(), "????",
                         Toast.LENGTH_SHORT).show();  
               intent.setClassName( "com.github.musetoolkit",
                             "com.github.musetoolkit.Touch" );
                  startActivity(intent);                          
                   break;                   
             case 10:
                 Toast.makeText(getApplicationContext(), "??",
                         Toast.LENGTH_SHORT).show();  
               intent.setClassName( "com.github.musetoolkit",
                             "com.github.musetoolkit.About" );
                  startActivity(intent);                          
                   break;                   
             case 11:
               finish();                        
                   break;                   
            
             
             }             
            
      }
   }

      //???????????????????????????????????

  
/*  
  //?????????setOnClickListener()??????????????
  //???????????????layout???????????????????????
  public void onClick(View v){
    switch (v.getId()){
    case R.id.sine_button:
      Intent sine = new Intent(this,Sine.class);
      startActivity(sine);
      break;
    case R.id.triangle_button:
      Intent triangle = new Intent(this,Triangle.class);
      startActivity(triangle);
      break;      
    case R.id.sawtooth_button:
      Intent sawtooth = new Intent(this,Sawtooth.class);
      startActivity(sawtooth);
      break;
    case R.id.wnoise_button:
      Intent wnoise = new Intent(this,Wnoise.class);
      startActivity(wnoise);
      break;
//    case R.id.pnoise_button:
//      Intent pnoise = new Intent(this,Pnoise.class);
//      startActivity(pnoise);
//      break;
    case R.id.spl_button:
      Intent spl = new Intent(this,Spl.class);
      startActivity(spl);
      break;
    case R.id.test_button:
      Intent test = new Intent(this,Test.class);
      startActivity(test);
      break;
    case R.id.piano_button:
      Intent piano = new Intent(this,Piano.class);
      startActivity(piano);
      break;
    case R.id.touch_button:
      Intent touch = new Intent(this,Touch.class);
      startActivity(touch);
      break;
    case R.id.about_button:
      Intent about = new Intent(this,About.class);
      startActivity(about);
      break;
    case R.id.exit_button:  //?????????????????????Activity?????????Android??????
      finish();
      break;

    //case the other buttons...  
    }
  }  
  
  
  @Override
  public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    //Set up click listeners for all buttons
    //?????????????????????
//    View guitarButton = findViewById(R.id.guitar_button);
//    guitarButton.setOnClickListener(this);
//    View violinButton = findViewById(R.id.violin_button);
//    violinButton.setOnClickListener(this);
    View sineButton = findViewById(R.id.sine_button);
    sineButton.setOnClickListener(this);    
    View triangleButton = findViewById(R.id.triangle_button);
    triangleButton.setOnClickListener(this);
    View sawtoothButton = findViewById(R.id.sawtooth_button);
    sawtoothButton.setOnClickListener(this);
    View wnoiseButton = findViewById(R.id.wnoise_button);
    wnoiseButton.setOnClickListener(this);    
//    View pnoiseButton = findViewById(R.id.pnoise_button);
//    pnoiseButton.setOnClickListener(this);  
    View splButton = findViewById(R.id.spl_button);
    splButton.setOnClickListener(this);  
//    View sensorButton = findViewById(R.id.sensor_button);
//    sensorButton.setOnClickListener(this);      
    View testButton = findViewById(R.id.test_button);
    testButton.setOnClickListener(this);  
    View pianoButton = findViewById(R.id.piano_button);
    pianoButton.setOnClickListener(this);
    View touchButton = findViewById(R.id.touch_button);
    touchButton.setOnClickListener(this);
    View aboutButton = findViewById(R.id.about_button);
    aboutButton.setOnClickListener(this);
    View exitButton = findViewById(R.id.exit_button);
    exitButton.setOnClickListener(this);
  }
*/  
  //???????Back?????????????????
  //????????import???Android?
  //import android.view.KeyEvent;
  //import android.widget.Toast;
    private long exitTime = 0;  
    
    /** 
     * ???????????? 
     *  
     * ??? Activity ?? TabActivity ? onKeyDown ????????? dispatchKeyEvent 
     * ??? Activity ? onKeyDown ?????? 
     */  
      
    @Override  
    public boolean dispatchKeyEvent(KeyEvent event) {  
      if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {  
        if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {  
          this.exitApp();  
        }  
        return true;  
      }  
      return super.dispatchKeyEvent(event);  
    }  
      
    /** 
     * ????? 
     */  
    private void exitApp() {  
      // ??2???????  
      if ((System.currentTimeMillis() - exitTime) > 2000) {  
        Toast.makeText(CopyOfMainActivity.this, "??????????", Toast.LENGTH_SHORT).show();  
        exitTime = System.currentTimeMillis();  
      } else {  
        finish();  
      }  
    }

  @Override
  public void onClick(View v) {
    // TODO Auto-generated method stub
    
  }  
}




Java Source Code List

com.github.musetoolkit.About.java
com.github.musetoolkit.CalcActivity.java
com.github.musetoolkit.CopyOfMainActivity.java
com.github.musetoolkit.MainActivity.java
com.github.musetoolkit.Metro.java
com.github.musetoolkit.MoreActivity.java
com.github.musetoolkit.Piano.java
com.github.musetoolkit.Pnoise.java
com.github.musetoolkit.Sawtooth.java
com.github.musetoolkit.SignalActivity.java
com.github.musetoolkit.Sine.java
com.github.musetoolkit.Spl.java
com.github.musetoolkit.Splash.java
com.github.musetoolkit.Sweep.java
com.github.musetoolkit.TestActivity.java
com.github.musetoolkit.Test.java
com.github.musetoolkit.TheoryActivity.java
com.github.musetoolkit.Touch.java
com.github.musetoolkit.Triangle.java
com.github.musetoolkit.Wnoise.java