0

我有一个Android应用程序会改变,事情如下:

要启动的应用程序具有单个屏幕配置和数据管理(应用程序本身),我想将其修改为具有相同的应用程序但在多个屏幕上(屏幕设置、应用程序、信息等)并包含菜单选项 ..

在 onCreate 中,我有几个方法,而且还有几个类,我需要离开(否则)并与每个类的独立显示器交互,因为我可以做这些来得到这些......

代码看起来像这样......

package com.Test1;

导入 com.Test1.R.drawable;

公共类 Test1Activity 扩展 Activity {

public handler_thread handlerThread;
public TestInterface uartInterface;

EditText readText;                              
EditText writeText;                             
Spinner Option1Spinner;                         
Button writeButton, configButton;               


byte[] writeBuffer;

public Context global_context;
public boolean bConfiged = false;
public SharedPreferences sharePrefSettings;
Drawable originalDrawable;
public String act_string; 


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    readText = (EditText) findViewById(R.id.ReadValues);
    writeText = (EditText) findViewById(R.id.WriteValues);

    global_context = this;

    configButton = (Button) findViewById(R.id.configButton);
    writeButton = (Button) findViewById(R.id.WriteButton);

    originalDrawable = configButton.getBackground();

    '
    '
    '



    configButton.setOnClickListener(new View.OnClickListener() {

        // @Override
        public void onClick(View v) {
            '
    '
    '
        }

    });

    /* handle write click */
    writeButton.setOnClickListener(new View.OnClickListener() {

        // @Override
        public void onClick(View v) {
            '
    '
    '

            }
        }
    });

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    handlerThread = new handler_thread(handler);
    handlerThread.start();

}





protected void cleanPreference(){
        '
    '
    '
}



public class SelectedListener implements OnItemSelectedListener {
    public void onItemSelected(AdapterView<?> parent, View view, int pos,
            '
    '
    '
}

public class SelectedListener implements OnItemSelectedListener {
    public void onItemSelected(AdapterView<?> parent, View view, int pos,
            '
    '
    '
}




//@Override
public void onHomePressed() {
    onBackPressed();
}   

public void onBackPressed() {
    super.onBackPressed();
}   




private class handler_thread extends Thread {
    Handler mHandler;

    /* constructor */
    handler_thread(Handler h) {
        mHandler = h;
    }

    public void run() {
        Message msg;

        while (true) {

            try {
                Thread.sleep(200);
            } catch (InterruptedException e) {
            }

            status = Interface.ReadData(4096, readBuffer,actualNumBytes);

            if (status == 0x00 && actualNumBytes[0] > 0) {
                msg = mHandler.obtainMessage();
                mHandler.sendMessage(msg);
            }

        }
    }
}

}

4

1 回答 1

0

我认为,你必须使用 Bundle 争论。这个答案可以帮助你

https://stackoverflow.com/a/3913720/2382964

于 2013-05-14T18:51:13.000 回答