This is the main activity from which i'm passing the values to a class called choice.
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String x="";
for(int i=0;i<count;i++)
{
x+=songf[i]+" ";
}
Toast.makeText(getApplicationContext(), x, Toast.LENGTH_SHORT).show();
Choice o = new Choice();
o.initializeit(songf,sizef,linkf,indexf,count);
Intent ix=new Intent("com.example.harmony.CHOICE");
startActivity(ix);
}
/*public void doit()
{
Choice o = new Choice();
o.initializeit(songf,sizef,linkf,indexf,count);
}
*/
This is the class choice
public class Choice extends Activity implements OnClickListener{
Button b;
RadioButton rb1,rb2,rb3,rb4 ;
RadioGroup rg;
static String[] songf = new String[19];
static Integer[] indexf = new Integer[19];
static String[] linkf = new String[19];
static double[] sizef = new double[19];
static int count;
public static void initializeit(String[] song, double[] size, String[] link,Integer[] index, int c) {
// TODO Auto-generated method stub
songf=song;
sizef=size;
indexf=index;
linkf=link;
count=c;
String x="";
//x+=Integer.toString(count);
//Toast.makeText(getApplicationContext(), x, Toast.LENGTH_SHORT).show();
//for(int i=0;i<count;i++)
//{
// x+=songf[i]+" ";
// }
// Toast.makeText(getApplicationContext(), x, Toast.LENGTH_SHORT).show();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.choice);
b = (Button) findViewById(R.id.download);
rg = (RadioGroup) findViewById(R.id.radioGroup1);
rb1 = (RadioButton) findViewById(R.id.fcfs);
rb2 = (RadioButton) findViewById(R.id.sjf);
rb3 = (RadioButton) findViewById(R.id.priority);
b.setOnClickListener(this);
MainActivity o = new MainActivity();
o.doit();
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(rb1.isChecked())
{
for(int i=0;i<count;i++)
{
for(int j=0;j<count-i-1;j++)
{
if(indexf[j]>indexf[j+1])
{
int temp1=indexf[j];
indexf[j]=indexf[j+1];
indexf[j+1]=temp1;
String temp2=linkf[j];
linkf[j]=linkf[j+1];
linkf[j+1]=temp2;
String temp3=songf[j];
songf[j]=songf[j+1];
songf[j+1]=temp3;
double temp4=sizef[j];
sizef[j]=sizef[j+1];
sizef[j+1]=temp4;
}
}
}
String x="";
for(int i=0;i<count;i++)
{
x+=songf[i]+" ";
}
Toast.makeText(getApplicationContext(), x, Toast.LENGTH_SHORT).show();
}
else if(rb2.isChecked())
{
for(int i=0;i<count;i++)
{
for(int j=0;j<count-i-1;j++)
{
if(sizef[j]>sizef[j+1])
{
double temp1=sizef[j];
sizef[j]=sizef[j+1];
sizef[j+1]=temp1;
String temp2=linkf[j];
linkf[j]=linkf[j+1];
linkf[j+1]=temp2;
String temp3=songf[j];
songf[j]=songf[j+1];
songf[j+1]=temp3;
int temp4=indexf[j];
indexf[j]=indexf[j+1];
indexf[j+1]=temp4;
}
}
}
String x="";
for(int i=0;i<count;i++)
{
x+=songf[i]+" ";
}
x+=Integer.toString(count)+songf[0]+indexf[0];
Toast.makeText(getApplicationContext(), x, Toast.LENGTH_SHORT).show();
}
else if(rb3.isChecked())
{
String x="";
for(int i=0;i<count;i++)
{
x+=songf[i]+" ";
}
Toast.makeText(getApplicationContext(), x, Toast.LENGTH_SHORT).show();
}
}
}
The string values initialized in initializeit are not initialized and giving me null values. I cannot understand the issue. Please help me out.