현재 저는 Android 스튜디오 앱을 개발 중입니다. 이 앱은 버튼이있는지도를 표시해야합니다. 이 버튼을 누르면 날씨가 표시된 대화 상자가 나타납니다. 문제는 내가 누를 때마다 오류가 나타나는 것입니다. 은 (이미 날씨가 나는지도 활동내 콘텐츠를 표시하고 싶을 때 대화 상자가 작동하지 않는 이유는 무엇입니까?
이 호출 대화 상자에서 내지도 활동에 보여하지만 할 수 없기 때문에 작동 오류 것을 알고 :이 코드입니다
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
내 버튼 : 대화 상자에 대한
public void startDialogClima(View view) {
AlertDialog.Builder mBuilder = new AlertDialog.Builder(MapsActivity.this);
View mView = getLayoutInflater().inflate(R.layout.dialog_playas, null);
mBuilder.setView(mView);
climaText = (TextView) findViewById(R.id.climaText);
downloadTask.placeIdTask asyncTask = new downloadTask.placeIdTask(new downloadTask.AsyncResponse() {
public void processFinish(String weather_city, String weather_description, String weather_temperature, String weather_humidity, String weather_pressure, String weather_updatedOn, String weather_iconText, String sun_rise) {
climaText.setText(weather_temperature);
//desc.setText(weather_description);
//weatherIcon.setText(Html.fromHtml(weather_iconText));
}
});
asyncTask.execute("-34.83", "-56.17"); // asyncTask.execute("Latitude", "Longitude")
AlertDialog dialog = mBuilder.create();
dialog.show();
}
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:id="@+id/climaText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:layout_marginTop="20dp"
android:layout_marginStart="120dp"
/>
</LinearLayout