自分が書いたメソッドを呼び出そうとしています。1行を除いてコンパイルします...
public class http extends Activity {
httpMethod(); //will not compile
public void httpMethod(){
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://site/api/");
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
String test = "hello";
TextView myTextView = (TextView) findViewById(R.id.myTextView);
myTextView.setText(test);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
}
}
私は最高のJavaの人ではありませんが、そのようにメソッドを呼び出すと応答が得られると思います。ただし、「こんにちは」は表示されません。
メソッドを適切に呼び出すにはどうすればよいですか?