Volley 正在工作,当我关闭 listData 时,没有崩溃并且工作良好,但没有 listView:package com.example.tronksinc4d;import androidx.appcompat.app.AppCompatActivity;import android.content.Context;import android.content.Intent;import android.database.DataSetObserver;import android.os.Bundle;import android.util.Log;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.BaseAdapter;import android.widget.Button;import android.widget.ImageView;import android.widget.ListAdapter;import android.widget.ListView;import android.widget.TextView;import com.android.volley.Request;import com.android.volley.RequestQueue;import com.android.volley.Response;import com.android.volley.VolleyError;import com.android.volley.toolbox.JsonObjectRequest;import com.android.volley.toolbox.Volley;import com.google.gson.JsonArray;import com.google.gson.JsonObject;import com.squareup.picasso.Picasso;import com.squareup.picasso.PicassoProvider;import org.json.JSONArray;import org.json.JSONException;import org.json.JSONObject;import java.util.ArrayList;public class Home extends AppCompatActivity { public static prefconfig prefcoonfig; private TextView helloo; RequestQueue requestQueue; String url = "https://tronksinc4d.000webhostapp.com/show_all_movies.php"; ArrayList<listitem> listmovies = new ArrayList<listitem>(); ListView listView; TextView text_total, try_data; @Override `enter code here` protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); prefcoonfig = new prefconfig(this); helloo = (TextView) findViewById(R.id.hello); helloo.setText(" أهلا بك " + prefcoonfig.readname());
1 回答
慕少森
TA贡献2019条经验 获得超9个赞
从错误消息中可以清楚地看出尝试在空对象引用上调用虚拟方法 'void android.widget.TextView.setText(java.lang.CharSequence)' , textview 在getView中未正确初始化。正确的方法是
LayoutInflater layoutInflater = getLayoutInflater();
View view = layoutInflater.inflate(R.layout.row_item, null);
TextView Title = (TextView) view.findViewById(R.id.text_view_title);
TextView info = (TextView) view.findViewById(R.id.text_view_info);
ImageView img = (ImageView) view.findViewById(R.id.row_img);
添加回答
举报
0/150
提交
取消