将Android应用程序的代码修改为多个屏幕

时间:2013-05-14 17:33:34

标签: android package

我的Android应用程序会发生变化,问题如下:

要启动的应用程序有一个屏幕配置和数据管理(应用程序本身),我想修改它以拥有相同的应用程序,但在几个屏幕(屏幕设置,应用程序,信息等),还推广菜单选项..

在onCreate中,我有几个方法,而且还有几个方法,我需要离开(否则)并与每个类的独立显示交互,就像我可以做到的那样......

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

package com.Test1;

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

        }
    }
}

}

1 个答案:

答案 0 :(得分:0)

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

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