我想用Surface View創建一個指南針,我發現下面的代碼...但我不知道下面的代碼試圖實現什麼想法?下面的代碼是什麼? Android Surface Surface查看
這是一個實施的方法。我認爲該方法應該被調用一次,並且線程永遠運行,除非onPause方法被調用...但是當我試圖運行下面的代碼時,Paint類只被調用一次,然後退出...更新的位置傳感器被忽視。請幫忙。
@Override
public void surfaceCreated(SurfaceHolder holder) {
// TODO Auto-generated method stub
this.runDrawingThread = true;
new Thread(new Runnable()
{
public void run()
{
long l1 = System.currentTimeMillis();
long l2 = 0L;
int i = 0;
int j = 0;
long l3 = System.currentTimeMillis();
if (!Painter.this.runDrawingThread){
return;
}
if (j < 2)
{
Painter.this.onPaint(l3, true);
j++;
if ((l3 - l2)/1000L < 1L)
l2 = l3;
}
for (i = 0; ;i++)
{
Log.i("test", "i value " + i);
while (true)
{
l1 += 16L;
l3 = l1 - l3;
if (l3 < 0L)
break;
try
{
Log.i("inside","inside the thread");
Thread.sleep(l3);
}
catch (Exception localException)
{
}
}
Painter.this.onPaint(l3, false);
break;
}
}
}).start();
}
上面的代碼只是一個代碼片段..哦耶..請從下面的鏈接檢查此代碼,併發送給我你的想法或什麼是缺乏(如果你有時間)在此先感謝... http:///scamexdotexe.x10.mx/ – scamexdotexe 2012-02-12 02:08:52