Back to project page musetoolkit.
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.
package com.github.musetoolkit; /* w w w .ja v a 2s .co m*/ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.GridView; import android.widget.SimpleAdapter; import android.widget.TextView; import android.widget.Toast; import android.widget.AdapterView.OnItemClickListener; public class TestActivity extends Activity { private GridView mGridView; //MyGridView //?????? private int[] imageRes = { R.drawable.png07, R.drawable.png08, R.drawable.png09, R.drawable.png10 }; //?????? private String[] itemName = { "?????", "????", "??????", "????" }; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.testtab); // TextView textview = new TextView(this); // textview.setText("This is the Artists tab"); // setContentView(textview); 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(TestActivity.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.Spl" ); startActivity(intent); break; case 1: Toast.makeText(getApplicationContext(), "????", Toast.LENGTH_SHORT).show(); intent.setClassName( "com.github.musetoolkit", "com.github.musetoolkit.Test" ); startActivity(intent); break; case 2: Toast.makeText(getApplicationContext(), "??????", Toast.LENGTH_SHORT).show(); intent.setClassName( "com.github.musetoolkit", "com.github.musetoolkit.Piano" ); startActivity(intent); break; case 3: Toast.makeText(getApplicationContext(), "????", Toast.LENGTH_SHORT).show(); intent.setClassName( "com.github.musetoolkit", "com.github.musetoolkit.Touch" ); startActivity(intent); break; } } } }