با سلام خدمت دوستان
من داخل برنامه ام از لیست ویو استفاده می کنم و دیتا را با جیسون نمایش میدهم
میخواهم مقداری که کاربر از این لیست انتخاب کرده به یک اکتیوتی دیگه ارسال کنم ( 2 مقدار id , price) راه حلش چیه ؟
اینم کد mainactivity
کد پیاچپی:
import android . content . Intent ; import android . os . Bundle ; import android . view . Menu ; import android . view . MenuItem ; import ir . menu . tour5 . adapter . FeedListAdapter ; import ir . menu . tour5 . app . AppController ; import ir . menu . tour5 . data . FeedItem ; import java . io . UnsupportedEncodingException ; import java . util . ArrayList ; import java . util .List; import org . json . JSONArray ; import org . json . JSONException ; import org . json . JSONObject ; import android . annotation . SuppressLint ; import android . app . Activity ; import android . graphics . Color ; import android . graphics . drawable . ColorDrawable ; import android . widget . ListView ; import com . android . volley . Cache ; import com . android . volley . Cache . Entry ; import com . android . volley . Request . Method ; import com . android . volley . Response ; import com . android . volley . VolleyError ; import com . android . volley . VolleyLog ; import com . android . volley . toolbox . JsonObjectRequest ; public class MainActivity extends BaseActivity { private static final String TAG = MainActivity .class. getSimpleName (); private ListView listView ; private FeedListAdapter listAdapter ; private List< FeedItem > feedItems ; private String URL_FEED = "http://host.com/android/index3.php" ; @ Override protected void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ); setContentView ( R . layout . activity_main ); listView = ( ListView ) findViewById ( R . id .list); feedItems = new ArrayList < FeedItem >(); listAdapter = new FeedListAdapter ( this , feedItems ); listView . setAdapter ( listAdapter ); // We first check for cached request Cache cache = AppController . getInstance (). getRequestQueue (). getCache (); Entry entry = cache . get ( URL_FEED ); if ( entry != null ) { // fetch the data from cache try { String data = new String ( entry . data , "UTF-8" ); try { parseJsonFeed (new JSONObject ( data )); } catch ( JSONException e ) { e . printStackTrace (); } } catch ( UnsupportedEncodingException e ) { e . printStackTrace (); } } else { // making fresh volley request and getting json JsonObjectRequest jsonReq = new JsonObjectRequest ( Method . GET , URL_FEED , null , new Response . Listener < JSONObject >() { @ Override public void onResponse ( JSONObject response ) { VolleyLog . d ( TAG , "Response: " + response . toString ()); if ( response != null ) { parseJsonFeed ( response ); } } }, new Response . ErrorListener () { @ Override public void onErrorResponse ( VolleyError error ) { VolleyLog . d ( TAG , "Error: " + error . getMessage ()); } }); // Adding request to volley request queue AppController . getInstance (). addToRequestQueue ( jsonReq ); } } /** * Parsing json reponse and passing the data to feed view list adapter * */ private void parseJsonFeed ( JSONObject response ) { try { JSONArray feedArray = response . getJSONArray ( "feed" ); for ( int i = 0 ; i < feedArray . length (); i ++) { JSONObject feedObj = ( JSONObject ) feedArray . get ( i ); FeedItem item = new FeedItem (); item . setId ( feedObj . getInt ( "id" )); item . setName ( feedObj . getString ( "name" )); // Image might be null sometimes String image = feedObj . isNull ( "image" ) ? null : feedObj . getString ( "image" ); item . setImge ( image ); item . setprice ( feedObj . getString ( "price" )); item . setintro ( feedObj . getString ( "intro" )); item . setdate1 ( feedObj . getString ( "date1" )); item . setdate2 ( feedObj . getString ( "date2" )); item . setvalance ( feedObj . getString ( "valance" )); // url might be null sometimes String feedUrl = feedObj . isNull ( "url" ) ? null : feedObj . getString ( "url" ); item . setUrl ( feedUrl ); feedItems . add ( item ); } // notify data changes to list adapater listAdapter . notifyDataSetChanged (); } catch ( JSONException e ) { e . printStackTrace (); } } @ Override public boolean onCreateOptionsMenu ( Menu menu ) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater (). inflate ( R . menu . menu_main , menu ); return true ; } @ Override public boolean onOptionsItemSelected ( MenuItem item ) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item . getItemId (); //noinspection SimplifiableIfStatement switch ( id ) { case R . id . action_main : return true ; } return super . onOptionsItemSelected ( item ); } }