stackoverflow新手,请耐心等待。
我在课堂上遇到无法解决符号错误。
我有一个名为CameraPhotoActivity(下面)的课程:
package com.example.android.frapp;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
public class CameraPhotoActivity extends AppCompatActivity {
Button uploadButton, showUploadDataButton;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_camera_photo);
uploadButton = (Button) findViewById(R.id.uploadBtn);
showUploadDataButton = (Button) findViewById(R.id.showDataBtn);
uploadButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(getApplicationContext().UploadInfo.class));
}
});
showUploadDataButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// startActivity(new Intent(getApplicationContext().ShowData.class));
}
});
}
}
以下是我遇到问题的部分:
@Override
public void onClick(View view) {
startActivity(new Intent(getApplicationContext().UploadInfo.class));
}
错误发生在' UploadInfo.class'。
这表明我没有一个叫做“上传信息”的课程。但是,正如你将在下面看到的那样,我做了:
package com.example.android.frapp;
import android.app.ProgressDialog;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.firebase.client.Firebase;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.storage.StorageReference;
public class UploadInfo extends AppCompatActivity {
Button selectImageBtn, uploadButton;
ImageView user_image;
TextView title;
public static final int READ_EXTERNAL_STORAGE = 0;
public static final int GALLERY_INTENT = 2;
private ProgressDialog mProgressDialog;
private Firebase mRoofRef;
private Uri mImageUri = null;
private DatabaseReference mDatabaseRef;
private StorageReference mStorage;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.uploading_layout);
Firebase.setAndroidContext(this);
selectImageBtn = (Button) findViewById(R.id.selectImageBtn);
uploadButton = (Button) findViewById(R.id.uploadButton);
user_image = (ImageView) findViewById(R.id.user_image);
title = (TextView) findViewById(R.id.etTitle);
// inititalise the progress bar
mProgressDialog = new ProgressDialog(UploadInfo.this);
}
}
以下是清单文件,您将看到我已添加了' UploadInfo'类:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.frapp">
<uses-feature android:name="android.hardware.camera2" android:required="true"></uses-feature>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<application
android:name=".FireApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainLoginActivity" />
<activity android:name=".MainActivity" />
<activity
android:name=".Login"
android:label="@string/title_activity_login"
android:theme="@style/AppTheme" />
<activity
android:name=".LoginScreenActivity"
android:label="@string/title_activity_login_screen"
android:parentActivityName=".MainActivity"
android:theme="@style/AppTheme">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.android.frapp.MainActivity" />
</activity>
<activity
android:name=".CreateCaseActivity"
android:label="@string/title_activity_create_case"
android:theme="@style/AppTheme" />
<activity
android:name=".NoteTakerActivity"
android:label="@string/title_activity_note_taker"
android:theme="@style/AppTheme" />
<activity android:name=".AddMainNotesActivity"></activity>
<activity android:name=".CameraPhotoActivity"></activity>
<activity android:name=".CameraVideoActivity"></activity>
<activity android:name=".AudioActivity"></activity>
<activity android:name=".UploadInfo"></activity>
</application>
我的build.gradle文件如下:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.android.frapp"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:design:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:27.0.2'
implementation 'com.google.firebase:firebase-messaging:11.6.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.google.firebase:firebase-database:11.6.2'
compile 'com.google.firebase:firebase-crash:11.6.2'
compile 'com.google.firebase:firebase-auth:11.6.2'
compile 'com.google.firebase:firebase-storage:11.6.2'
compile 'com.firebase:firebase-client-android:2.5.2'
compile 'com.google.firebase:firebase-core:11.6.2'
compile 'com.firebaseui:firebase-ui-storage:1.2.0'
compile 'com.firebaseui:firebase-ui-database:1.2.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:cardview-v7:27.0.2'
compile 'com.android.support:recyclerview-v7:27.0.2'
implementation 'com.android.support:cardview-v7:27.0.2'
compile 'com.squareup.picasso:picasso:2.5.2'
// Firebase UI
compile 'com.firebaseui:firebase-ui-database:3.1.2'
compile 'com.android.support:recyclerview-v7:27.0.2'
}
apply plugin: 'com.google.gms.google-services'
我尝试了以下内容:
我希望我不会错过一些明显的东西,但我所尝试过的一切都是基于我之前的答案中所看到的。
请帮忙
答案 0 :(得分:1)
将行更改为:
startActivity(new Intent(CameraPhotoActivity.this , UploadInfo.class));