gpt4 book ai didi

android - 强制关闭设备上的 ListView 项目,但在模拟器中运行良好

转载 作者:行者123 更新时间:2023-11-30 03:51:13 25 4
gpt4 key购买 nike

<分区>

homeactivity.class

lv1.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long id) { if(image_details.get(position).getQueryType().equals("service_appointment")){
Intent intent1=new Intent(getApplicationContext(),SingleClick.class);
Bundle b = new Bundle();
b.putString("UserName", username);
b.putString("Password",password);
b.putString("id", image_details.get(position).getServiceRequestnum());
b.putString("id3", image_details.get(position).getId());
intent1.putExtras(b);
startActivity(intent1);

}
else {
Intent intent2=new Intent(HomeActivity.this,SingleClickComment.class);
Bundle b = new Bundle();
b.putString("UserName", username);
b.putString("Password",password);
b.putString("id", image_details.get(position).getId());
intent2.putExtras(b);
startActivity(intent2);
}
});

SingleClickComment.class

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.singleclick);
enquiry=(TextView) findViewById(R.id.serviceEnduiry_Id);
servicestatus=(TextView) findViewById(R.id.serviceappointmentstatus);
count1=(TextView) findViewById(R.id.Count1);
time1=(TextView) findViewById(R.id.Time1);
comment1=(TextView) findViewById(R.id.Comment1);
description1=(TextView) findViewById(R.id.DEscription1);
count3=(TextView) findViewById(R.id.Count2);
singleClickComment=(EditText) findViewById(R.id.singleclickcommententry);
singleClick=(Button) findViewById(R.id.singleclickcommentbutton);
ArrayList<Comment> image_details = new ArrayList<Comment>();
image_details = GetSearchResults();
System.out.println("imagedetails:"+image_details);
final ListView lv1 = (ListView) findViewById(R.id.list10);
lv1.setAdapter(new CustomListViewAdapter1(this, image_details));
count1.setText(size+" comments");
count3.setText(size+" comments");
Intent intent2 = getIntent();
Bundle b = intent2.getExtras();
final String username= b.getString("UserName");
System.out.println("username:"+username);
final String password= b.getString("Password");
System.out.println("password:"+password);
final String id2= b.getString("id");
System.out.println("id:"+id2);
singleClick.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//post();
String url = "http://192.168.0.199:8080/CarKonect/webresources/rest/commentInsert";

List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);

nameValuePairs.add(new BasicNameValuePair("UserName", username));
nameValuePairs.add(new BasicNameValuePair("Password",password));
nameValuePairs.add(new BasicNameValuePair("id", id2));
nameValuePairs.add(new BasicNameValuePair("description",
singleClickComment.getText().toString()));
JSONParser1 jParser = new JSONParser1();
// getting JSON string from URL along with list values
JSONObject json = jParser.makeHttpRequest(url, method,
nameValuePairs);

try {

String value=(String) json.get("error");
System.out.println("error:"+value);
String value1=(String) json.get("Inserted");
System.out.println("insert value:"+value1);
if(value1.equals("true"))
{
Intent homeintent=new Intent(SingleClickComment.this,HomeActivity.class);
Bundle b = new Bundle();
b.putString("UserName", username);
b.putString("Password",password);
homeintent.putExtras(b);
startActivity(homeintent);
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}

private ArrayList<Comment> GetSearchResults() {
// TODO Auto-generated method stub

Intent intent2 = getIntent();
Bundle b = intent2.getExtras();
final String username= b.getString("UserName");
System.out.println("username:"+username);
final String password= b.getString("Password");
System.out.println("password:"+password);
final String id2= b.getString("id");
System.out.println("id:"+id2);

ArrayList<Comment> results = new ArrayList<Comment>();
String url = "http://192.168.0.199:8080/CarKonect/webresources/rest/readSingleQuery";

List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("id", id2));
nameValuePairs.add(new BasicNameValuePair("UserName", username));
nameValuePairs.add(new BasicNameValuePair("Password",password));
JSONParser1 jParser = new JSONParser1();

// getting JSON string from URL along with list values
JSONObject json = jParser.makeHttpRequest(url, method,nameValuePairs);
try {
Comment undergraduateDetailsPojoObj = new Comment();
String description=(String) json.get("Description");
System.out.println(description);
enquires=(String) json.get("Query_Id");
System.out.println( enquires);
String title=(String) json.get("Title");
System.out.println(title);
servicestatusapp=(String) json.get("Query_Status");
System.out.println(servicestatusapp);
JSONArray jsonArray = json.getJSONArray("historyList");
size=jsonArray.length();
System.out.println(size);
for(int i=0;i<=size;i++)
{
JSONObject c1 = jsonArray.getJSONObject(i);
username1=(String) c1.get("Response_From_Name");
inserteddate1=(String) c1.get("Inserted_Date");
description4=(String) c1.get("Description");
undergraduateDetailsPojoObj.setUserName(username1);
undergraduateDetailsPojoObj.setImage(1);
undergraduateDetailsPojoObj.setInsertedDate(inserteddate1);
undergraduateDetailsPojoObj.setDescription(description4);
results.add(undergraduateDetailsPojoObj);
}

}catch (JSONException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
return results;
}
}

singleclick.xml:

<?xml version="1.0" encoding="utf-8"?>  
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#2f322a" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.01"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.99"
android:orientation="vertical" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linearLayout5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
style="@style/TitleBar"
android:layout_width = "fill_parent"
android:layout_height="43dp"
android:gravity="left|top">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width = "wrap_content"
android:layout_height="50dp"
android:gravity="left"
android:background="@drawable/customerbg"
>
<Button style="@style/TitleBarOperation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/user"
android:id="@+id/userslide"
android:textSize="10dp"
android:layout_marginTop="2dp"
android:layout_marginRight="10dip"
android:layout_marginLeft="4dip"
android:background="@drawable/home_bg"
android:layout_gravity="center"
android:layout_marginBottom="5dp"
/>
<ImageView android:layout_width="1px"
android:layout_height="fill_parent"
android:background="@drawable/divider"
android:layout_marginRight="5dip"/>
<Button style="@style/TitleBarOperation"
android:drawableTop="@drawable/write"
android:text="Write"
android:id="@+id/onwrite"
android:textSize="10dp"
android:layout_marginRight="10dip"
android:layout_marginLeft="4dip"
android:layout_marginBottom = "5dip"
android:paddingBottom = "3dip"
android:background="@drawable/home_bg"
android:layout_gravity="center"
/>
<Button style="@style/TitleBarOperation"
android:id="@+id/onschedule"
android:layout_width="50dp"
android:drawableTop="@drawable/schedule"
android:text="Schedule"
android:textSize="10dp"
android:layout_marginRight="5dip"
android:layout_marginLeft="4dip"
android:layout_marginBottom = "5dip"
android:paddingBottom = "3dip"
android:background="@drawable/home_bg"
android:layout_gravity="center"
/>
<Button style="@style/TitleBarOperation"
android:layout_width="50dp"
android:id="@+id/feedback"
android:drawableTop="@drawable/feedback"
android:text="Feedback"
android:textSize="10dp"
android:layout_marginTop="3dp"
android:layout_marginRight="10dip"
android:layout_marginLeft="4dip"
android:layout_marginBottom = "5dip"
android:paddingBottom = "3dip"
android:background="@drawable/home_bg"
android:layout_gravity="center"
/>
<Button style="@style/TitleBarOperation"
android:layout_width="50dp"
android:layout_marginTop="1dp"
android:id="@+id/truevalue"
android:drawableTop="@drawable/truevalue"
android:text="Truevalue"
android:textSize="10dp"
android:layout_marginRight="15dip"
android:layout_marginLeft="4dip"
android:layout_marginBottom = "5dip"
android:paddingBottom = "3dip" android:background="@drawable/home_bg"
android:layout_gravity="center"
/>
<ImageView android:layout_width="1px"
android:layout_height="fill_parent"
android:background="@drawable/divider"
android:layout_marginRight="1dip"/>
<Button style="@style/TitleBarOperation"
android:drawableTop="@drawable/dealer"
android:id="@+id/dealer"
android:layout_marginTop="7dp"
android:layout_marginRight="10dip"
android:layout_marginLeft="4dip"
android:layout_marginBottom = "5dip"
android:paddingBottom = "3dip"
android:background="@drawable/home_bg"
android:layout_gravity="center"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width = "fill_parent"
android:layout_height="wrap_content"
android:background="#C0C0C0">
<TextView
android:id="@+id/serviceEnduiry_Id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="30sp"
/>
<TextView
android:id="@+id/serviceappointmentstatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#2f322a"
android:paddingLeft="10sp"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="2sp"
android:paddingLeft="10sp"
>
<ImageView
android:id="@+id/ImageCity1"
android:paddingTop="3sp"
android:layout_width="20sp"
android:src="@drawable/coment"
android:layout_height="20sp"
android:contentDescription="desc"
android:paddingLeft="5sp"/>
<TextView
android:id="@+id/Count1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:layout_marginRight="50sp"
android:textColor="#A1A1A1"
android:paddingLeft="5sp" />
<TextView
android:id="@+id/Time1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:textColor="#A1A1A1" />
</LinearLayout>
<TextView
android:id="@+id/Comment1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:textStyle="bold"
android:layout_marginRight="30sp"
android:textColor="#ffffff"
android:paddingLeft="10sp"
android:layout_marginBottom="4sp" />
<TextView
android:id="@+id/DEscription1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13sp"
android:paddingLeft="10sp"
android:textColor="#A1A1A1" />
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width = "fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10sp"
android:layout_marginRight="10sp" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="WikiCode - Custom ExpandableListView"
/>
<ExpandableListView
android:id="@+id/ExpandableListView01" android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:background="#C0C0C0"
android:childDivider="#848482"
>
</ExpandableListView>
<TextView
android:id="@+id/Count2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:layout_marginRight="50sp"
android:textColor="#A1A1A1"
android:paddingLeft="5sp" />
<ListView android:id="@+id/list10"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#C0C0C0"
android:textColor="#A1A1A1"
></ListView>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="2sp"
android:paddingLeft="10sp"
>
<EditText android:id="@+id/singleclickcommententry"
android:layout_width="150sp"
android:layout_height="wrap_content"
/>
<Button android:id="@+id/singleclickcommentbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="send"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</TableRow>
</LinearLayout>
</LinearLayout>
</FrameLayout>

LOGCAT 报告

01-02 12:18:19.072: E/AndroidRuntime(3286): FATAL EXCEPTION: main 01-02 12:18:19.072: E/AndroidRuntime(3286): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.androidactionbar/com.example.androidactionbar.SingleClickComment}: java.lang.NullPointerException 01-02 12:18:19.072: E/AndroidRuntime(3286): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) 01-02 12:18:19.072: E/AndroidRuntime(3286): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 01-02 12:18:19.072: E/AndroidRuntime(3286): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 01-02 12:18:19.072: E/AndroidRuntime(3286): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 01-02 12:18:19.072: E/AndroidRuntime(3286): at android.os.Handler.dispatchMessage(Handler.java:99) 01-02 12:18:19.072: E/AndroidRuntime(3286): at android.os.Looper.loop(Looper.java:123) 01-02 12:18:19.072: E/AndroidRuntime(3286): at android.app.ActivityThread.main(ActivityThread.java:4627) 01-02 12:18:19.072: E/AndroidRuntime(3286): at java.lang.reflect.Method.invokeNative(Native Method) 01-02 12:18:19.072: E/AndroidRuntime(3286): at java.lang.reflect.Method.invoke(Method.java:521) 01-02 12:18:19.072: E/AndroidRuntime(3286): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) 01-02 12:18:19.072: E/AndroidRuntime(3286): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 01-02 12:18:19.072: E/AndroidRuntime(3286): at dalvik.system.NativeStart.main(Native Method) 01-02 12:18:19.072: E/AndroidRuntime(3286): Caused by: java.lang.NullPointerException 01-02 12:18:19.072: E/AndroidRuntime(3286): at com.example.androidactionbar.SingleClickComment.onCreate(SingleClickComment.java:82) 01-02 12:18:19.072: E/AndroidRuntime(3286): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 01-02 12:18:19.072: E/AndroidRuntime(3286): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 01-02 12:18:19.072: E/AndroidRuntime(3286): ... 11 more

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com