实现Android文本按钮更简单的方法

但是代码要简单很多,也无需xml文件的帮助,上面按钮也是可以触发的:

Android

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

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwspdw.html