Domanda

Background info:

So I have a file chooser portion that chooses and does a toast that indicates the file selected, I would like to have a essentially what the toast says but in a indicated TextView object.

Code:

//File selection code
// Create a file instance from the URI
    final File file = FileUtils.getFile(uri); 
    Toast.makeText(FileTransfer.this, "File Selected: " + file.getAbsolutePath(),  
    Toast.LENGTH_LONG).show();

Is there a dynamic text adapter I can use or what is a way to going about doing this?

È stato utile?

Soluzione

Add this to your layout XML:

<TextView
    android:id="@+id/fileNameTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

and then in your Java code (if part of an Activity context) instead of the Toast logic:

TextView fileNameTextView = ((TextView)findViewById(R.id.fileNameTextView);
fileNameTextView.setText(file.getAbsolutePath());

Altri suggerimenti

To answer your second question on Voicu's answer, you can set screenOrientation in the Manifest file.

<activity
   android:name=".."
   android:screenOrientation="portrait" />
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top