private void showFileChooser() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
intent.addCategory(Intent.CATEGORY_OPENABLE); try {
startActivityForResult(
Intent.createChooser(intent, "Select a txt File to import(one phone one line)"),
FILE_SELECT_CODE);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(this, "Please install a File Manager.",
Toast.LENGTH_SHORT).show();
}
} 启动文件选择的intent
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
intent.addCategory(Intent.CATEGORY_OPENABLE); try {
startActivityForResult(
Intent.createChooser(intent, "Select a txt File to import(one phone one line)"),
FILE_SELECT_CODE);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(this, "Please install a File Manager.",
Toast.LENGTH_SHORT).show();
}
} 启动文件选择的intent
如果这句输出了,且后面号码正确,说明文件读取正常,否则就是文件读取问题,与edittext无关
下面的设置我看是没有问题的,如果有问题,把contact_list的布局内容弄出来
//import phone numbers is :123456789
只要这句话没输出,说明没到这一步,极可能是
resultCode == RESULT_OK
根到就没到这个条件里,与edittext一点关系都没有
先理清问题所在是解决问题的关键
你好,多谢你的回复,results_ok下面的是有打印的,把文本文件都打印出来了。
布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" > <TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:text="Set contact list(separate by ;)"
android:textSize="20sp" /> <EditText
android:id="@+id/contact_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/hint"
android:minLines="3"
android:text="" /> <Button
android:id="@+id/txt_select"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp"
android:text="Import from file" /> <Button
android:id="@+id/save_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/save_button" /></LinearLayout>