I have created a custom class from a tutorial online. It works fine, but what I want to do is make it so that I can set the text of the view, just like I would any other view. How is that accomplished. Here is the xml for the custom view
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">
<ImageView
android:id="@+id/file_image_holder"
android:layout_width="110dip"
android:layout_height="110dip"
android:src="@drawable/pdf_icon" />
<TextView
android:id="@+id/file_name_holder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="File Name Here" />
</LinearLayout>
What I am trying to achieve is this
FileView fileView = new FileView(this)
fileView.setText("text")
TextView filename = (TextView)findViewById(R.id.file_name_holder);
filename.setText("someFile.exe");
On another note ... you can use hint to give your users a greyed out text prompt that they won't have to erase when entering a filename. In your XML replace android:text
with android:hint
for your TextView.