Java 为什么赢了';在Android Studio中找到这些带ButterKnife的文本视图不是吗?

Java 为什么赢了';在Android Studio中找到这些带ButterKnife的文本视图不是吗?,java,android,butterknife,Java,Android,Butterknife,我的代码有问题吗?由于某些原因,我无法从我的activity\u main.xml获取文本视图,以链接到我的MainActivity.java文件 这是我的密码 package com.dredaydesigns.radiostationfinder; import android.R; import android.app.Activity; import android.location.Location; import android.os.Bundle; import andr

我的代码有问题吗?由于某些原因,我无法从我的
activity\u main.xml
获取文本视图,以链接到我的
MainActivity.java
文件

这是我的密码

    package com.dredaydesigns.radiostationfinder;

import android.R;
import android.app.Activity;
import android.location.Location;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationServices;
import com.squareup.okhttp.Call;
import com.squareup.okhttp.Callback;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;

import butterknife.Bind;


public class MainActivity extends Activity implements GoogleApiClient.ConnectionCallbacks {
String longitude;
    String latitude;
   // String HTTPRadioURL = "https://transition.fcc.gov/fcc-bin/fmq?state=&call=&city=&arn=&serv=FC&vac=3&freq=0.0&fre2=107.9&facid=&asrn=&class=&dkt=&list=0&dist=100&dlat2="
        //    + latitude + "&mlat2=&slat2=&NS=N&dlon2="
          //  + longitude +"&mlon2=&slon2=&EW=W&size=9";

    public static final String TAG = MainActivity.class.getSimpleName();
    private RadioData mRadioData;

    private GoogleApiClient mGoogleApiClient;
    private Location mLastLocation;


private GoogleApiClient mGoogleApiClient;
private Location mLastLocation;
@Bind(R.id.longitudeLabel) TextView mLongitudeLabel;
@Bind(R.id.latitudeLabel) TextView mLatitudeLabel;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.list_content);
    ButterKnife.bind(this);

        double latitude = 32;
        double longitude = -96;
        double latitudeStations;
        double longitudeStations;
        @Bind(R.id.latitudeLabel) TextView latitude;
        @Bind(R.id.longitudeLabel) TextView longitude;

        final RadioData[] mRadioData = new RadioData[1];
       //String radioFinderURL = "http://data.fcc.gov/lpfmapi/rest/v1/lat/" + latitude + "/long/" + longitude + "?format=json&secondchannel=true";
       //String HTTPRadioURL = "https://transition.fcc.gov/fcc-bin/fmq?state=&call=&city=&arn=&serv=FC&vac=3&freq=0.0&fre2=107.9&facid=&asrn=&class=&dkt=&list=0&dist=100&dlat2="
          //      + latitude + "&mlat2=&slat2=&NS=N&dlon2="
           //     + longitude +"&mlon2=&slon2=&EW=W&size=9";
        String radioFinderURL = "http://dredaycreative.com/json/radioData.json";

        OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder()
                .url(radioFinderURL)
                .build();
        Call call = client.newCall(request);
        call.enqueue(new Callback() {
            @Override
            public void onFailure(Request request, IOException e) {

            }

            @Override
            public void onResponse(Response response) throws IOException {
                try {
                    String jsonData = response.body().string();
                    Log.v(TAG,jsonData);
                    if (response.isSuccessful()) {
                        mRadioData[0] = getCurrentDetails(jsonData);

                    }

                } catch (IOException e) {
                    Log.e(TAG, "Exception Caught: ", e);
                }
                catch(JSONException e){
                    Log.e(TAG, "Exception Caught:", e);
                }
            }
        });








    }

    private RadioData getCurrentDetails(String jsonData) throws JSONException {
        JSONObject radioData = new JSONObject(jsonData);
        String callSign;
        double latitudeStations;
        double longitudeStations;
        int frequency;
        JSONArray jsonArray = radioData.getJSONArray("array");
        for(int i =0; i<jsonArray.length(); i++){
            callSign = radioData.getJSONObject(i+"")
                    .getJSONArray("array").getJSONObject(i).getString("FIELD1");
            frequency = Integer.parseInt(radioData.getJSONObject(i+"")
                    .getJSONArray("array").getJSONObject(i).getString("FIELD2"));
            longitudeStations = Double.parseDouble(radioData.getJSONObject(i+"")
                    .getJSONArray("array").getJSONObject(i).getString("FIELD20"));
            latitudeStations = Double.parseDouble(radioData.getJSONObject(i+"")
                    .getJSONArray("array").getJSONObject(i).getString("FIELD24"));
        Log.i(TAG, "From JSON: " + callSign + frequency + latitudeStations  + longitudeStations);

        RadioData radioFinder = new RadioData();

        }
            return new RadioData();



    }

    protected synchronized void buildGoogleApiClient() {
        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener((GoogleApiClient.OnConnectionFailedListener) this)
                .addApi(LocationServices.API)
                .build();


    }


    @Override
    public void onConnected(Bundle bundle) {
        mLastLocation = LocationServices.FusedLocationApi.getLastLocation(
                mGoogleApiClient);
        if (mLastLocation != null) {
            latitudeLabel.setText(String.valueOf(mLastLocation.getLatitude()));
            longitude.setText(String.valueOf(mLastLocation.getLongitude()));
        }
    }


    @Override
    public void onConnectionSuspended(int i) {

    }


}
它总是显示为红色,如果我尝试运行它,它会得到一个无法解析的符号

根据要求,这里是gradle文件!谢谢

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.dredaydesigns.radiostationfinder"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.google.android.gms:play-services:7.5.0'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.squareup.okhttp:okhttp:2.4.0'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.googlecode.json-simple:json-simple:1.1'
    compile 'com.google.code.gson:gson:1.7.2'

}

您忘记在
onCreate
方法中调用
ButterKnife.bind(this)

如果您不这样做,butterknife将不会插入您的视图,您将遇到问题。

我已经这样做了,但无论我如何做或使用什么,仍然无法识别它们?我也试着重建。请把你的毕业档案贴在这里。顺便说一句,你有打字错误。应该是
ButterKnife.bind(this)
而不是小写的
k
。谢谢你的提醒,编辑它吧!如果有帮助,请在回答时打勾!
double latitude = 32;
double longitude = -96;
double latitudeStations;
double longitudeStations;
latitude = (TextView) findViewById(R.id.latitudeLabel);
longitude = (TextView) findViewById(R.id.longitudeLabel);
apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.dredaydesigns.radiostationfinder"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.google.android.gms:play-services:7.5.0'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.squareup.okhttp:okhttp:2.4.0'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.googlecode.json-simple:json-simple:1.1'
    compile 'com.google.code.gson:gson:1.7.2'

}