在我的应用中,我收到文档的网址,我想在我的应用中显示它们,而不是在任何外部应用中。
这是我用过的代码。
public class Doc_webview extends Activity implements AdvancedWebView.Listener{
private AdvancedWebView mWebView;
String tag="doc";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_doc_webview);
mWebView = (AdvancedWebView) findViewById(R.id.webview);
//mWebView.setListener(this, this);
Intent intent=getIntent();
Log.e(tag,"url "+Uri.parse(intent.getStringExtra("URL")).toString());
mWebView.setListener(this, this);
mWebView.loadUrl("http://docs.google.com/gview?embedded=true&url="+Uri.parse(intent.getStringExtra("URL")).toString());
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
mWebView.onActivityResult(requestCode, resultCode, intent);
// ...
}
@Override
public void onPageStarted(String url, Bitmap favicon) {
Log.e(tag,"page started "+url);
}
@Override
public void onPageFinished(String url) {
Log.e(tag,"page finished "+url);
}
@Override
public void onPageError(int errorCode, String description, String failingUrl) {
Log.e(tag,"page error "+description);
}
@Override
public void onDownloadRequested(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
Log.e(tag,"download started "+url);
}
@Override
public void onExternalPageRequest(String url) {
Log.e(tag,"page request "+url);
}
}
我只想显示它们,而不是打开它们进行编辑。
答案 0 :(得分:1)
我正在使用此代码在我的网页浏览中打开文档
<ComboBox x:Name="comboBox"
Width="158"
Height="44"
Background="Transparent"
BorderBrush="#551B2830"
Foreground="Black">
<ComboBoxItem TextBlock.TextAlignment="Center">Mousehover me</ComboBoxItem>
<ComboBoxItem TextBlock.TextAlignment="Center">To see the bad </ComboBoxItem>
<ComboBoxItem TextBlock.TextAlignment="Center">blue rectangle</ComboBoxItem>
<ComboBox.ItemContainerStyle>
<Style TargetType="ComboBoxItem">
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Template">
<Setter.Value>
<!--This Does the Magic-->
<ControlTemplate TargetType="{x:Type ComboBoxItem}">
<Border x:Name="Bd"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="true">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="True" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ComboBox.ItemContainerStyle>
</ComboBox>
我的网址是
Google文档网址:http://docs.google.com/gview?embedded=true&url= \
我的文档网址:http://52.24.60.37/guilt/uploads/termcondition/profile60252550.pdf
附加URL以在WebView中打开文档