0

I am using monodroid and I want to start a new activity which has parameters I DONT want to use intent.putextra or any bundles

For example this is my activity

namespace BoostITAndroid
{
[Activity(Label = "My Activity")]
public partial class UploadDealership : ListActivity
{

    private List<Dealership> listDealers;
    private Vehiclestoupload ul;
    private int selectedDealershipID = 0;
    private String[] Options;

    public UploadDealership(Vehiclestoupload uploadList, List<Dealership> listOfDealers)
    {
        this.ul = uploadList;
        this.listDealers = listOfDealers;
    }

so this activity has two parameters.

Below I am trying to start the activity

Intent uld = new Intent(this, typeof(UploadDealership(this, listOfDealers)));
                StartActivity(uld);

But everything is underlined red so this doesnt work.

How can I start an Activity with parameters?

Cam Connor
  • 1,231
  • 2
  • 25
  • 40
  • You could provide a singleton with a private constructor and a public `get(Context ctx)` which will either return a new list of items or the current one if it's already been created. Then you can access it from any activity or fragment w/o passing anything. – ChiefTwoPencils Aug 22 '13 at 20:53
  • do you have an example? – Cam Connor Aug 22 '13 at 20:55
  • Maybe you are looking to use Preferences? http://stackoverflow.com/questions/13762032/shared-preferences-in-mono-android – Slack Shot Aug 26 '13 at 17:10

1 Answers1

0

Maybe this might be useful to you. This is to carry a string between activities.

On Activity One:

     //Intent i = new Intent()
    EditText editText = (EditText) findViewById(R.id.editText);
    String message = editText.getText().toString();
    intent.putExtra(EXTRA_MESSAGE, message);
     //StartActivity(i);

On Activity Two:

    // Get the Intent that started this activity and extract the string
Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);

// Capture the layout's TextView and set the string as its text
TextView textView = (TextView) findViewById(R.id.textView);
textView.setText(message);