我有一个因任何原因而无法打开的PDF阅读活动。我怀疑该问题源于我之前导入的API。当我在PDF阅读活动中预览XML文件时,我注意到PDF-API旁边有一个问号,表明它没有被android studio识别,如果有人可以帮助我,我将非常感激把这个想出来(解决;计算出;弄明白。这是代码:
XML:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".PDFReader">
<com.github.barteksc.pdfviewer.PDFView
android:id="@+id/pdfViewer"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
</com.github.barteksc.pdfviewer.PDFView>
</android.support.constraint.ConstraintLayout>
Java:
package com.androidcodefinder.loginscreendemo.Analytics;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import com.androidcodefinder.loginscreendemo.MainActivity;
import com.androidcodefinder.loginscreendemo.R;
import com.androidcodefinder.loginscreendemo.SignUpActivity;
import com.androidcodefinder.loginscreendemo.Utils.BottomNavigationViewHelper;
import com.github.barteksc.pdfviewer.PDFView;
import com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx;
public class AnalyticsActivity extends AppCompatActivity {
private static final String TAG = "AnalyticsActivity";
private Context mContext= AnalyticsActivity.this;
private static final int ACTIVITY_NUM = 0;
private Button pdfViwer;
private Button pdfViwer2;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.analytics_activity);
Log.d(TAG,"onCreate: started");
setupBottomNavigationView();
pdfViwer=(Button)findViewById(R.id.pdf23);
pdfViwer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(AnalyticsActivity.this,PDFView.class);
startActivity(intent);
}
});
pdfViwer2=(Button)findViewById(R.id.pdf22);
pdfViwer2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(AnalyticsActivity.this,PDFView.class);
startActivity(intent);
}
});
}
private void setupBottomNavigationView(){
Log.d(TAG,"setupBottomNavigationView: setting up BottomNavigationView");
BottomNavigationViewEx bottomNavigationViewEx = (BottomNavigationViewEx) findViewById(R.id.bottomNavViewBar);
BottomNavigationViewHelper.setupBottomNavigationView(bottomNavigationViewEx);
BottomNavigationViewHelper.enableNavigation(mContext, bottomNavigationViewEx);
Menu menu = bottomNavigationViewEx.getMenu();
MenuItem menuItem = menu.getItem(ACTIVITY_NUM);
menuItem.setChecked(true);
}
}
清单代码:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androidcodefinder.loginscreendemo">
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_background"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SignUpActivity" />
<activity android:name=".zippage" />
<activity android:name=".Catalysts.CatalystsActivity" />
<activity android:name=".Profile.ProfileActivity" />
<activity android:name=".Analytics.AnalyticsActivity" />
<activity android:name=".postpg" />
<activity android:name=".postp1" />
<activity android:name=".post2" />
<activity android:name=".postend" />
<activity android:name=".PDFReader"></activity>
</application>
</manifest>
答案 0 :(得分:1)
修改
像这样在AndroidManifest.xml中声明您的活动
def inc_dup(a):
i = 0
while i < len(a):
j = i + 1
while j < len(a):
if a[i] == a[j]:
a[j] + 1
else:
j += 1
i += 1
s = [3,2,4,5,4,3,6]
inc_dup(s)
print(s)
print(sum(s))
不是这个
<application
.
.
android:theme="@style/AppTheme">
<activity android:name=".PDFReader">
</activity>
.
.
</application>
是吗?
Intent intent = new Intent(AnalyticsActivity.this,PDFView.class);
答案 1 :(得分:0)
您正在寻找视图
pdfViwer=(Button)findViewById(R.id.pdf23);
pdfViwer2=(Button)findViewById(R.id.pdf22);
id为pdf23,pdf22的文件,但是这两个在您的xml文件中不可用。因此它将引发运行时异常。