Hai qualche Consiglio/Critica/Suggerimento relativo al forum? Diccelo qui.Ti entusiasma l'idea di un forum italiano di Android? Vorresti partecipare in qualche modo?Scrivi un Tutorial o fai richiesta di ammissione nello Staff
public class GiocatoreFragment extends Fragment{ private static int id= 1; //id = Giocatore.id // url to get all products list private static String url_giocatore = "http://giocapp.altervista.org/get_giocatore.php/?id="+id+".php"; // JSON Node names private static final String TAG_SUCCESS = "success"; private static final String TAG_GIOCATORE = "Giocatore"; private static final String TAG_ID_GIOCATORE = "IdGiocatore"; private static final String TAG_COGNOME = "Cognome"; private static final String TAG_NOME = "Nome"; private static final String TAG_INDIRIZZO = "Indirizzo"; private static final String TAG_DATA_NASCITA = "DataNascita"; // Progress Dialog private ProgressDialog pDialog; String new_id; EditText txtId; EditText txtNome; EditText txtCognome; EditText txtDataNascita; EditText txtIndirizzo; // JSON parser class // products JSONArray JSONArray giocatore = null; JSONParser jsonParser = new JSONParser(); @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { //returning our layout file //change R.layout.yourlayoutfilename for each of your fragments View view = inflater.inflate(R.layout.fragment_giocatore, container, false); //prima era return inflater ecc. int success; try { ; List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("id", ""+id)); // getting product details by making HTTP request // Note that product details url will use GET request JSONObject json = jsonParser.makeHttpRequest( url_giocatore, "GET", params); // check your log for json response Log.d("Single Product Details", json.toString()); // json success tag success = json.getInt(TAG_SUCCESS); if (success == 1) { // successfully received product details JSONArray giocatoreObj = json .getJSONArray(TAG_GIOCATORE); // JSON Array // get first product object from JSON Array JSONObject giocatore = giocatoreObj.getJSONObject(0); // product with this pid found // Edit Text txtId = (EditText) view.findViewById(R.id.txtId);//usato l'oggetto view txtCognome = (EditText) view.findViewById(R.id.txtCognome); txtNome= (EditText) view.findViewById(R.id.txtNome); txtDataNascita = (EditText) view.findViewById(R.id.txtDataNascita); txtIndirizzo = (EditText) view.findViewById(R.id.txtIndirizzo); // display product data in EditText txtId.setText(giocatore.getString(TAG_ID_GIOCATORE)); txtNome.setText(giocatore.getString(TAG_NOME)); txtCognome.setText(giocatore.getString(TAG_COGNOME)); txtDataNascita.setText(giocatore.getString(TAG_DATA_NASCITA)); txtIndirizzo.setText(giocatore.getString(TAG_INDIRIZZO)); }else{ // product with pid not found } } catch (JSONException e) { e.printStackTrace(); } return view; } @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); //you can set the title for your toolbar here for different fragments different titles getActivity().setTitle("Giocatore"); }}
//List<NameValuePair> params = new ArrayList<NameValuePair>(); //params.add(new BasicNameValuePair("id", ""+id)); // getting product details by making HTTP request // Note that product details url will use GET request //JSONObject json = jsonParser.makeHttpRequest( // url_giocatore, "GET", params); String j="{\"Giocatore\":[{\"IdGiocatore\":\"4\",\"Cognome\":\"Neri\",\"Nome\":\"Luigi\",\"DataNascita\":\"1989-09-19\",\"Indirizzo\":\"Via Finlandia 54\"}],\"success\":1}"; JSONObject json=new JSONObject(j);