Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

list files at root in scrollable TextView

Signed-off-by: Stefan Naewe <stefan.naewe@gmail.com>
  • Loading branch information...
commit 21bcacdc9b137489fecd0fa0ad3a1493cab636f2 1 parent c7e8074
@snaewe authored
View
1  AndroidManifest.xml
@@ -20,6 +20,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
+ <activity android:name="ChoiceActivity"></activity>
</application>
</manifest>
View
15 res/layout/activity_system_information.xml
@@ -7,19 +7,20 @@
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_centerHorizontal="true"
- android:layout_centerVertical="true"
- android:text="@string/hello_world"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentRight="true"
+ android:layout_below="@+id/choices"
+ android:maxLines="1000"
+ android:scrollbars="vertical"
tools:context=".SystemInformation" />
<Spinner
android:id="@+id/choices"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_above="@+id/textView1"
- android:layout_alignRight="@+id/textView1"
- android:layout_marginBottom="57dp"
- android:layout_marginRight="57dp"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentTop="true"
android:entries="@array/choices_array" />
</RelativeLayout>
View
29 src/com/example/systemexplorer/SystemInformation.java
@@ -1,20 +1,49 @@
package com.example.systemexplorer;
import android.os.Bundle;
+import android.annotation.TargetApi;
import android.app.Activity;
+import android.text.method.ScrollingMovementMethod;
import android.view.Menu;
import android.widget.Spinner;
+import android.widget.TextView;
+
import com.example.systemexplorer.ChoiceActivity;
+import java.io.*;
+
public class SystemInformation extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+
setContentView(R.layout.activity_system_information);
Spinner spinner = (Spinner) findViewById(R.id.choices);
ChoiceActivity listener = new ChoiceActivity();
spinner.setOnItemSelectedListener(listener);
+
+ TextView tv = (TextView)findViewById(R.id.textView1);
+ tv.setMovementMethod(new ScrollingMovementMethod());
+
+ File[] files = new File("/").listFiles();
+ for (File aFile : files) {
+ tv.append(aFile.getAbsolutePath());
+ tv.append(" ");
+ if(aFile.isFile()) {
+ tv.append(Long.valueOf(aFile.length()).toString());
+ } else {
+ tv.append("00000000");
+ }
+ tv.append(" ");
+ boolean x = false; /* aFile.canExecute(); */
+ boolean r = aFile.canRead();
+ boolean w = aFile.canWrite();
+ tv.append(r ? "R" : "-");
+ tv.append(w ? "W" : "-");
+ tv.append(x ? "X" : "-");
+ tv.append("\n");
+ }
}
@Override
Please sign in to comment.
Something went wrong with that request. Please try again.