java - Making checkbox checked in android with php and MySql -


hi guys trying make checkbox in app checked when receives data on php , mysql. hope understand going ask, because english not good. in images can see layout app , database. post php file , part of code. problem is, if let both checkboxes checked, because receive true. idea checkbox part should proof string. e.g. (if result == "male"){ setcheckboxmale(true); }... , on. doesn't work way because result boolean. can do? pls me. thanks.

layout android

mysql databse

get_data.php:

session_start();  if(isset($_get['id'])){  $id = $_get['id'];  $query = "select st_id, st_name, st_surname, st_gender t_studnets  = $id"; }else{ $query = "select st_id, st_name, st_surname, st_gender t_studnets"; }   require_once("dbconnect.php");    $result = mysqli_query($con,$query) or die('error in query: $query' .mysql_error());  $output = array();  while($row = mysqli_fetch_assoc($result)){     $output[] = $row; } print (json_encode($output)); mysqli_close($con); ?> 

receive.java:

@override     protected void onpostexecute(boolean result) {         if (result == true) {              etname.settext(data.getname());             etsurname.settext(data.getsurname());             etgender.settext(data.getgender());             checkboxmale.setchecked(true);             checkboxfemale.setchecked(true);          } else {             checkboxmale.setchecked(false);             checkboxfemale.setchecked(false);             toast.maketext(getactivity(), "error", toast.length_long).show();         }          dialog.dismiss();     } 

it if showed data receive in android code. if i'm reading right recieving gender string either "male" or "female". if that's true said , write:

if(data.getgender().equals("male"){   checkboxmale.setchecked(true);   checkboxfemale.setchecked(false); }else{   checkboxfemale.setchecked(true);   checkboxmale.setchecked(false); } 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -