android - Source not found. TextView -
i novice in java , android. want change text on activity via settext(). xml-code:
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context="com.example.p0081viewbyid.mainactivity$placeholderfragment" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" android:id="@+id/mytext" /> </relativelayout>
this part of java - code :
package com.example.p0081viewbyid; import android.app.activity; import android.app.fragment; import android.os.bundle; import android.view.layoutinflater; import android.view.menu; import android.view.menuitem; import android.view.view; import android.view.viewgroup; import android.widget.textview; public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); textview mytextview = (textview)findviewbyid(r.id.mytext); mytextview.settext("new text in textview");//application close on place if (savedinstancestate == null) { getfragmentmanager().begintransaction() .add(r.id.container, new placeholderfragment()).commit(); } } }
this application close on settext method cause "source not found". error? tried fix changing such as:
mytextview.settext("new text in textview".tostring()); mytextview.settext(integer.tostring("new text in textview"))
but same error.
Comments
Post a Comment