Android 我想开发一个实时图形应用程序,但它没有';行不通

Android 我想开发一个实时图形应用程序,但它没有';行不通,android,Android,这是它在emulator上运行的代码,但它不提供实时值 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); GraphView graph1 = (GraphView)findViewById(R.id.main_graph1); Series = new

这是它在emulator上运行的代码,但它不提供实时值

 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    GraphView graph1 = (GraphView)findViewById(R.id.main_graph1);

    Series = new LineGraphSeries<DataPoint>();
    graph1.addSeries(Series);
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GraphView graph1=(GraphView)findViewById(R.id.main_graph1);
系列=新的LineGraphSeries();
图1.添加系列(系列);
在这里,我将使用附加数据的线程模拟实时:

 protected void onResume(){
    super.onResume();

    new Thread(new Runnable() {

        public void run() {

            for(int i = 0; i<100; i++);
            runOnUiThread(new Runnable() {

                public void run() {
                    addEntry();
                }
            });

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

                e.printStackTrace();
            }


        }


    });
}
protectedvoid onResume(){
super.onResume();
新线程(newrunnable()){
公开募捐{
对于(int i=0;i问题:

1.)只有在对线程对象(缺少)调用
start
函数时,才会执行线程


2.
for(int i=0;i您忘记在for之后调用
start
。我没有收到它。您能澄清一下您所说的吗?非常感谢。它成功了,现在显示了实时值。我很高兴我能提供帮助
new Thread(new Runnable() {
    public void run() {
        for(int i = 0; i<100; i++) // ; removed 
        runOnUiThread(new Runnable() {

            public void run() {
                addEntry();
            }
        });
        try {
            Thread.sleep(600);
        } catch (InterruptedException e) {

            e.printStackTrace();
        }
    }
}).start(); // invoke start for execution