我使用来自Listview
数据库的soap WebService
开发了一个MySQL
应用。现在我的数据库中插入了一个订单意味着此时间(插入新订单)通知消息显示在我的Android设备上。如果我点击通知消息意味着应用程序运行的时间并在我的Listview
数据库中插入每个新订单时自动成功显示MySQL
。我在这里使用的方法是什么?请帮帮我。
这是我的RetailerActivity.java
代码:
public class RetailerActivity extends Activity {
ListView list;
private static final String SOAP_ACTION = "http://xcart.com/customerData1";
private static final String METHOD_NAME = "customerData1";
private static final String NAMESPACE = "http://xcart.com";
private static final String URL = "http://192.168.1.168:8089/XcartLogin/services/RetailerWs?wsdl";
private static final String KEY_STATUS = "status";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE ht = new HttpTransportSE(URL);
try {
ht.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
SoapPrimitive s = response;
String str = s.toString();
String resultArr[] = str.split("&");
list=(ListView)findViewById(R.id.list);
list.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1,resultArr));
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
String status = parent.getItemAtPosition(position).toString();
String[] status1 = status.split(" ");
String StrStatus = status1[1].toString();
Intent in = new Intent(getApplicationContext(), SingleMenuItemActivity.class);
in.putExtra(KEY_STATUS, StrStatus);
startActivity(in);
}
});
}
catch (Exception e) {
e.printStackTrace();
}
}
}
请在这里Listview
成功显示。但新订单插入我的数据库意味着插入新订单的时间Notification
消息显示在Android设备上。现在我必须点击通知meassage意味着它是显示更新Listview
。我该怎么办????????我必须在这里使用什么方法????
答案 0 :(得分:1)
如果您在ListView中获取新数据中的数据,那么我认为您必须做的只是
adapter.notifyDataSetChanged();
// adapter
是ArrayAdapter
的实例。