2017-04-07 8 views
0

タブ付きアクティビティ用のライブタイマーを作成したいと思います。シンボルメソッド - タブ付きアビリティが見つかりません

しかし、これは私が取得エラーです:

Error:(29, 38) error: cannot find symbol method runOnUniThread()

これは私のコードです:

package com.example.Sci.livetimeanddate; 

import android.icu.text.SimpleDateFormat; 
import android.os.Build; 
import android.support.annotation.Nullable; 
import android.support.annotation.RequiresApi; 
import android.support.v4.app.Fragment; 
import android.os.Bundle; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.ViewGroup; 
import android.widget.Button; 
import android.widget.TextView; 
import android.widget.Toast; 

public class sub_page01 extends Fragment { 
    private static final String TAG = "Sub_page01"; 

    @Nullable 
    @Override 
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 
     final View view = inflater.inflate(R.layout.fragment_sub_page01,container,false); 

     Thread t = new Thread() { 
      public void run() { 
       try { 
        while (!isInterrupted()) { 
         Thread.sleep(1000); 
         getActivity().runOnUniThread(new Runnable() { 
          @RequiresApi(api = Build.VERSION_CODES.N) 
          public void run() { 
           TextView tdate = (TextView) view.findViewById(R.id.date); 
           long date = System.currentTimeMillis(); 
           SimpleDateFormat sdf = new SimpleDateFormat("MMM dd yyyy\nhh-mm-ss a"); 
           String dateString = sdf.format(date); 
           tdate.setText(dateString); 
          } 
         }); 
        } 
       } catch (InterruptedException e) { 
       } 
      } 
     }; 
     t.start(); 
     return view; 
    } 
} 

私は問題が何であるかわかりません。

答えて

0

runOnUniThreadに入力ミスがあります。 runOnUiThread

+0

があります。ありがとうございました。 – SciToMe

関連する問題