我已经创建了显示从水库全部内容的应用程序/文件夹原料
I have created a app that displays all the content from res/raw folder.
我要当我的.doc文件单击它应该打开,我可以查看其内容。
I need that when i click on .doc file it should open and I can view its content.
请帮我。
我有ThinkFree的。
I have ThinkFree.
enter code here
public class FileList extends ListActivity {
public static final Field[] fields = R.raw.class.getFields();
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<Field>(this, R.layout.row, R.id.weekofday, fields));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
//super.onListItemClick(l, v, position, id);
String selection = l.getItemAtPosition(position).toString();
Toast.makeText(this, selection, Toast.LENGTH_SHORT).show();
Intent i = new Intent();
i.setAction(android.content.Intent.ACTION_VIEW);
startActivity(i);
}
}
您想要什么是不可能的。第三方应用程序将无法读取Word文档出您的原始资源。
What you want is not possible. A third-party application will not be able to read a Word document out of your raw resources.
目前最好的,你可以将文件从原始资源的某个地方(例如,外部存储),然后调用拷贝 startActivity()
上的 ACTION_VIEW
意图
具有乌里
指向可读的拷贝,也有正确的MIME类型
At best, you could copy the file from the raw resource someplace (e.g., external storage), then call startActivity()
on an ACTION_VIEW
Intent
that has a Uri
pointing to the readable copy and also has the proper MIME type.
当然,这只是上有一个Word文档浏览器的设备上工作。
Of course, this will only work on a device that has a Word document viewer on it.