我在Android上开发应用程序方面很陌生,而且我被当前项目阻止了:我尝试从服务器上的数据库接收信息并将其显示在列表中。
我能够这样做,但无法找到使用setOnItemClickListener的方法来访问另一个活动(无法点击它)。当我播放应用程序时,它会抛出以下消息:
"D/AbsListView: unregisterIRListener() is called".
以下是我制作的代码部分:
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_history);
listView_Formular = (ListView) findViewById(R.id.listEquipment);
listView_Formular.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(History_Formular.this, Work_Order_Resume.class);
String message = "abc";
TextView nom = (TextView) findViewById(R.id.ID_name);
intent.putExtra("id_formular", nom.getText().toString());
System.out.println(nom.getText().toString());
startActivity(intent);
}
});`
我试图将setOnClickListener()放在invokeWS()方法中,但没有改变任何东西(这里是带有onSuccess()的invokeWS())
public void invokeWSGet(RequestParams params){
AsyncHttpClient client = new AsyncHttpClient();
client.get( "http://192.168.1.20:8181/RestServer/iscs/workorders/",params ,new AsyncHttpResponseHandler() {
public void onSuccess(int statusCode, cz.msebera.android.httpclient.Header[] none, byte[] b) {
String result = new String(b);
JSONArray jarr = null;
List<JSONObject> jsons = new ArrayList<JSONObject>();
History_Formular.WorkOrderAdapter adapterLayout = new History_Formular.WorkOrderAdapter(History_Formular.this, all_Formular_Json);
listView_Formular = (ListView) findViewById(R.id.listEquipment);
if (listView_Formular.getCount()>0) {
adapterLayout.clear();
listView_Formular.setAdapter(adapterLayout);
listView_Formular.deferNotifyDataSetChanged();
}
try {
jarr = new JSONArray(result);
for(int i = 0; i<jarr.length();i++){
jsons.add(jarr.getJSONObject(i));
Work_Order_POJO work_order_converted = toWork_Order(jsons.get(i));
all_Formular_Json.add(i, work_order_converted);
}
} catch (JSONException e) {
e.printStackTrace();
}
System.out.println(result);
String[] all_request = result.split(",");
for(int i=0; i<all_request.length; i++) {
System.out.println(all_request[i]);
}
// JSON Object
JSONObject obj = new JSONObject();
adapterLayout = new History_Formular.WorkOrderAdapter(History_Formular.this, all_Formular_Json);
listView_Formular.setAdapter(adapterLayout);
}
感谢您的帮助!
答案 0 :(得分:0)
尝试从system
方法
onSuccess()
然后在listView_Formular = (ListView) findViewById(R.id.listEquipment);
方法之外声明listView_Formular
变量。
onCreate()