Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9149871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:32:09+00:00 2026-06-17T11:32:09+00:00

Why won’t the intent work properly? MainActivity is a graph that originally plotted one

  • 0

Why won’t the intent work properly? MainActivity is a graph that originally plotted one of the lines from an array (series1Numbers).I have another class (Main2Activity) with a spinner that i would like to have populate the (series1numbers) Array in MainActivity thereby generating my graph. Currently the graph line for (series1numbers) is blank which makes alot of sense because i have not been able to figure out how to populate it with the single number from (Main2Activity). I have searched and searched and not been able to connect the dots for this issue.

Main Activity.java

package com.example;
import java.util.Arrays;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import com.androidplot.series.XYSeries;
import com.androidplot.xy.LineAndPointFormatter;
import com.androidplot.xy.SimpleXYSeries;
import com.androidplot.xy.XYPlot;

/**
* The simplest possible example of using AndroidPlot to plot some data.
*/
public class MainActivity extends Activity
{

private XYPlot mySimpleXYPlot;

@Override
public void onCreate(Bundle savedInstanceState)
{

super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent intename = getIntent();
String name = (String) intename.getSerializableExtra("series1Numbers");



// initialize our XYPlot reference:
mySimpleXYPlot = (XYPlot) findViewById(R.id.mySimpleXYPlot);

// Create a couple arrays of y-values to plot:
Number[] series1Numbers ={name};
Number[] series2Numbers = {-4, -4, -5, -4, -4, -4, -3, -7, -4, -2, -4, -5, -5, -5};

// Turn the above arrays into XYSeries':
XYSeries series1 = new SimpleXYSeries(Arrays.asList(series1Numbers), 
// SimpleXYSeries takes a List so turn our array into a List
SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, 
// Y_VALS_ONLY means use the element index as the x value
"Series1");                             
// Set the display title of the series

// same as above
XYSeries series2 = new SimpleXYSeries(Arrays.asList(series2Numbers), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "Series2");

// Create a formatter to use for drawing a series using LineAndPointRenderer:
LineAndPointFormatter series1Format = new LineAndPointFormatter(
        Color.rgb(0, 200, 0),                   // line color
        Color.rgb(0, 100, 0),                   // point color
        null);                                  // fill color (none)

// add a new series' to the xyplot:
mySimpleXYPlot.addSeries(series1, series1Format);

// same as above:
mySimpleXYPlot.addSeries(series2,
        new LineAndPointFormatter(Color.rgb(0, 0, 200), Color.rgb(0, 0, 100), null));


// reduce the number of range labels
mySimpleXYPlot.setTicksPerRangeLabel(3);

// by default, AndroidPlot displays developer guides to aid in laying out your plot.
// To get rid of them call disableAllMarkup():
mySimpleXYPlot.disableAllMarkup();

}

Main2Activity.java

package com.example;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.AdapterView.OnItemSelectedListener;

public class Main2Activity extends Activity implements OnItemSelectedListener {

//TextView series1Numbers ;
Spinner spin;
String[] series1Numbers = { "-1", "-2", "-3", "-4", "-5",
   "-6", "-7", "-8" , "-9" , "-10" };
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main2);

//series1Numbers  = (TextView) findViewById(R.id.series1Numbers );

Spinner spin = (Spinner) findViewById(R.id.spinner);
spin.setOnItemSelectedListener(this);

ArrayAdapter<String> aa = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, series1Numbers);

spin.setAdapter(aa);
}

@Override
public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
// TODO Auto-generated method stub
// series1Numbers .setText(items[position]);
    if (position == 1){
      Intent intentObj = new Intent(Main2Activity.this, MainActivity.class);
      intentObj.putExtra("series1Numbers", series1Numbers);
      startActivity(intentObj);

    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:32:10+00:00Added an answer on June 17, 2026 at 11:32 am
    Bundle b=new Bundle();
    b.putStringArray(key, new String[]{value1, value2});
    Intent i=new Intent(context, Class);
    i.putExtras(b);
    

    In order to read:

    Bundle b=this.getIntent().getExtras();
    String[] array=b.getStringArray(key);
    

    Hope this will help you. 🙂

    For more info., Refer this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why won't this work? $stmt = $pdo->prepare(SELECT :columns FROM table); $stmt->bindParam(':columns', implode(', ', $columns),
This won't work and i'm getting an error from the ORDER BY param for
Codeigniter won't redirect the url oauth://application properly, pinning it after the current domain like
Why won't this xml schema validate ? Visual studio says that the simpleContent tag
why won't this work? function login(){ if(window.XMLHttpRequest){ ajax=new XMLHttpRequest(); }else if(window.ActiveXObject){ ajax=new ActiveXObject(Microsoft.XMLHTTP); }
Why won't this work? public static int[] GetListOfAllDaysForMonths() { static int[] MonthDays = new
Why won't Environment.GetEnvironmentVariable(variableName) get a variable's value if the call is made from within
Why won't this work? View1 loads View2. In view2: - (void) goToView { View3
Why won't this simple Applescript snippet work? set x to 0 set thePath to
Why won't the following work in XSLT1.0? <xsl:template name=GenerateSummaryOld> <xsl:param name=Content /> <xsl:param name=Length

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.