0
我能够阅读PDF文件,但我有一个问题如何看到同样的观点(布局)PDF内容
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button OpenPDF = (Button) findViewById(R.id.button);
OpenPDF.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
File pdfFile = new File("/sdcard/Test.pdf");
if(pdfFile.exists())
{
Uri path = Uri.fromFile(pdfFile);
Intent pdfIntent = new Intent(Intent.ACTION_VIEW);
pdfIntent.setDataAndType(path, "application/pdf");
pdfIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try
{
startActivity(pdfIntent);
}
catch(ActivityNotFoundException e)
{
Toast.makeText(PDFTest.this, "No Application available to view pdf", Toast.LENGTH_LONG).show();
}
}
}
});
}
现在用的是上面的代码,当我点击按钮,它带我到另一个视图PDF内容可见。我不想使用两个活动。但我想看到同一视图中的PDF内容。怎么做。如何停止导航到下一个视图。 我的XML文件是:
`<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<Button android:text="Button"
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
</LinearLayout>
`
任何人都可以在这方面帮助我。
但代码不在SVN中。任何替代方法?我能够查看PDF文件,但希望打开相同的活动。只需在该按钮下面。 –
SVN如何处理这个问题?您打开一个PDF后,打开一个意图在另一个程序中打开PDF(例如Adobe,Aldiko)。如果你想直接在你的应用程序中显示PDF,你需要自己渲染它。 – Thommy