Forum Xamarin Xamarin.Android

How to refresh the intent putextra after filtering/sorting the list view?

merbsmerbs PHMember ✭✭

I'm new to xamarin, I'm having this problem whenever I search or filter my ListView, and click the first item.. it returns the 1st case..which is Mt Batulao as shown on the screenshot below, Is there a way to refresh the intent.put extra? what should I do? I'm stuck. Am I missing something In my intent?

My ListView

my code:

my main activity:

    private List<Mountain> mMountains;
    private ListView mListView;
    private EditText mSearch;
    private Mountain mt = null;
    private Intent i = null;

 protected override void OnCreate(Bundle bundle)

        mListView = FindViewById<ListView>(Resource.Id.listView);
        mSearch = FindViewById<EditText>(Resource.Id.etSearch);            

        mSearch.TextChanged += mSearch_TextChanged;

        mMountains = MountainsData.MountainList;
        mListView.ItemClick += mListView_ItemClick;

        mAdapter = new MountainsAdapter(this, Resource.Layout.ml_model, mMountains);
        mListView.Adapter = mAdapter;

    private void mListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        int itemPosition = e.Position;

    private void OpenDetailActivity(int pos)
        mt = mMountains[pos];
        i = new Intent(this, typeof(DetailActivity));

        i.PutExtra("IMG", mt.MtImg);
        i.PutExtra("MTNAME", mt.MtName);
        i.PutExtra("MTLOC01", mt.Location01);
        i.PutExtra("MTLOC02", mt.Location02);
        i.PutExtra("DESC01", mt.Description01);
        i.PutExtra("DESC02", mt.Description02);
        i.PutExtra("TRAIL01", mt.Trail01);
        i.PutExtra("TRAIL02", mt.Trail02);
        i.PutExtra("ITERENARY01", mt.Itenerary01);
        i.PutExtra("ITERENARY02", mt.Iterenary02);


My DetailActivity

  private TextView dmtname, dmtloc1, dmtloc2, ddesc1, ddesc2, dtrail1, dtrail2, dite1, dite2;
    private ImageView dmtimg;
    protected override void OnCreate(Bundle savedInstanceState)

        dmtname = FindViewById<TextView>(Resource.Id.mtname);
        dmtimg = FindViewById<ImageView>(Resource.Id.mtimg);
        dmtloc1 = FindViewById<TextView>(Resource.Id.mtlocation1);
        dmtloc2 = FindViewById<TextView>(Resource.Id.mtlocation2);
        ddesc1 = FindViewById<TextView>(Resource.Id.description1);
        ddesc2 = FindViewById<TextView>(Resource.Id.description2);
        dtrail1 = FindViewById<TextView>(Resource.Id.trail1);
        dtrail2 = FindViewById<TextView>(Resource.Id.trail2);
        dite1 = FindViewById<TextView>(Resource.Id.iterenary1);
        dite2 = FindViewById<TextView>(Resource.Id.iterenary2);

        Android.Content.Intent i = this.Intent;
        string name = i.Extras.GetString("MTNAME");
        int img = i.Extras.GetInt("IMG");
        string loc01 = i.Extras.GetString("MTLOC01");
        string loc02 = i.Extras.GetString("MTLOC02");
        string desc01 = i.Extras.GetString("DESC01");
        string desc02 = i.Extras.GetString("DESC02");
        string trail01 = i.Extras.GetString("TRAIL01");
        string trail02 = i.Extras.GetString("TRAIL02");
        string ite01 = i.Extras.GetString("ITERENARY01");
        string ite02 = i.Extras.GetString("ITERENARY01");

        dmtname.Text = name;
        dmtloc1.Text = loc01;
        dmtloc2.Text = loc02;
        ddesc1.Text = desc01;
        ddesc2.Text = desc02;
        dtrail1.Text = trail01;
        dtrail2.Text = trail02;
        dite1.Text = ite01;
        dite2.Text = ite02;

Sign In or Register to comment.