これをもう一度試す
私はこのコードのサンプルを持っていますが、それは完全ではありませんが、私の主張を理解するはずです
public class MainActivity extends Activity {
ListView list1;
LazyAdapter adapter;
String nUdid;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
final Context context = this;
setContentView(R.layout.main);
TextView viewtitle1 = (TextView) findViewById(R.id.textView1);
JSONObject j = new JSONObject();
try {
j.put("action", "udid_get_products");
j.put("success", "true");
j.put("content", "udid product list");
j.put("data", nUdid);
} catch (JSONException e1) {
e1.printStackTrace();
}
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.xxxxxxxxx.com/yyyy/test.php");
}
}
このコード スニペットは oncreate メソッドにあります。
私がする必要があるのはこれです
public class MainActivity extends Activity {
ListView list1;
LazyAdapter adapter;
String nUdid;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
myNewFunction();
}
public void myNewFunction() {
final Context context = this;
TextView viewtitle1 = (TextView) findViewById(R.id.textView1);
JSONObject j = new JSONObject();
try {
j.put("action", "udid_get_products");
j.put("success", "true");
j.put("content", "udid product list");
j.put("data", nUdid);
} catch (JSONException e1) {
e1.printStackTrace();
}
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.xxxxxxxxx.com/yyyy/test.php");
}
}
これはそのまま機能しますか、それとも関数名 myNewFunction に続く () で何か追加する必要がありますか。oncreate メソッドのスニペット 'Bundle savedInstanceState' が myNewFunction 構文で必要かどうか。