实现Android文本按钮更简单的方法
依然与前面是类似的效果:
相关阅读:Android使用SimpleAdapter实现TextView按钮
但是代码要简单很多,也无需xml文件的帮助,上面按钮也是可以触发的:
import Android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class EagleZip extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
String[] tKeyStr=new String[]{"压缩","解压","返回"};
ListView tListView=new ListView(this);
ArrayAdapter<String> tAdapter = new ArrayAdapter<String>
(this,android.R.layout.simple_list_item_1, tKeyStr);
tListView.setAdapter(tAdapter);
setContentView(tListView);
}
}