I wanna ask something about android programming..so, I have a value from one class called list_movie, here is the code > I only post a half
public void adapter_listview() {
ListAdapter adapter = new SimpleAdapter(this, dftr,R.layout.list_item,new String[] { "title", "id"}, new int[] {R.id.tangk, R.id.kodeangk});
setListAdapter(adapter);
ListView lv = getListView();
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
String kode_ang = ((TextView) view.findViewById(R.id.kodeangk)).getText().toString();
Intent in = new Intent(getApplicationContext(), studio.class);
in.putExtra("kode_intent", kode_ang);
startActivity(in);
}
});
}
So, I have a value "kode_intent" that contains id (This id is getting from a field id_movie in a table) . Next, it used in a class named studio..here is the code
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.studio);
Bundle b = getIntent().getExtras();
kode = b.getString("kode_intent");
ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
postParameters.add(new BasicNameValuePair("id_movie", kode.getText().toString())); >> this line "kode" is getting an error
so my question is, how to pass the value of kode = b.getString("kode_intent")
into postParameters.add(new BasicNameValuePair("id_movie", kode.getText().toString()));
here is my php code:
$db_host = "127.0.0.1";
$db_uid = "root";
$db_pass = "";
$db_name = "platinum";
$db_con = mysql_connect($db_host,$db_uid,$db_pass) or die('could not connect');
mysql_select_db($db_name);
$sql = "Select studio_name, date from cinema where id_movie = '". $_POST["id_movie"]."'";
$result = mysql_query($sql);
while($row=mysql_fetch_assoc($result))
$output[]=$row;
print(json_encode($output));
mysql_close();
Since I'm new in android programming, any help would be so great for me.. thank's
I've tried to change the postParameters.add(new BasicNameValuePair("id_film", kode.getText().toString()));
into this one postParameters.add(new BasicNameValuePair("id_movie", kode));
It seems fine..but now I've got another error.here is the code :
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.studio);
Bundle b = getIntent().getExtras();
kode = b.getString("kode_intent");
ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
postParameters.add(new BasicNameValuePair("id_movie", kode));
try
{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://10.0.2.2/cinemainfo/movie_time.php");
HttpResponse response = httpclient.execute(httppost,postParameters);
HttpEntity entity = response.getEntity();
is = entity.getContent();
Log.e("Pass 1", "success!");
}
catch(Exception e)
{
Log.e("Fail 1", e.toString());
Toast.makeText(getApplicationContext(), "Invalid IP Address",
Toast.LENGTH_LONG).show();
}
I've got error on this line HttpResponse response = httpclient.execute(httppost,postParameters);
>> execute has an error message : "The method execute(HttpUriRequest, HttpContext) in the type HttpClient is not applicable for the arguments (HttpPost,
ArrayList)"
did I do something wrong???