java - Cannot find symbol method findViewByInt -
i have created tabbed activity , wish 1 of tabs display current time , date. have linked fragments having issues displaying time , date.
this error:
error:(34, 61) error: cannot find symbol method findviewbyid(int)
and also:
error:(31, 25) error: cannot find symbol method runonuithread()
this code;
package com.example.user.plannerv2; 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"; // private button btntest; @nullable @override public view oncreateview(layoutinflater inflater, @nullable viewgroup container, @nullable bundle savedinstancestate) { view view = inflater.inflate(r.layout.fragment_sub_page01,container,false); thread t = new thread() { public void run() { try { while (!isinterrupted()) { thread.sleep(1000); runonuithread(new runnable() { @requiresapi(api = build.version_codes.n) public void run() { textview tdate = (textview) 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; } any grateful.
you inside fragment, should use view.findviewbyid( ) instead.
replace: textview tdate = (textview) findviewbyid(r.id.date);
to: textview tdate = (textview) view.findviewbyid(r.id.date);
Comments
Post a Comment