How to get the data from the Mainactivity.java to the adapter.java for its textview .setText for viewing?

152
May 20, 2019, at 05:20 AM

Problem on getting data from MainActivity.java to Yearamountadapter.java.

What code should i write in order retrieve data from the Mainactivity into the Yearamountadapter.java?

I have tried to use the intent method to retrive data from mainactivity.java to Yearamountadapter.java but the getIntent shows red.

This is Mainactivity.java which extends AppCompactActivity

float FVend = (float)(PMT * ((basepwr - 1) / (r/100*n))); //end formula
                    float totalmethodend = CI + FVend;
                    String noyears = Double.toString(t);
                    String end = Float.toString(totalmethodend); //end compound
                    //Below coding To transfer data end and noyears to Yearamountadapter line 48&49 .setText
                    //Using noyears as increment for loop at Activity 2
                    Intent gotoyearamountadapter = new Intent( MainActivity.this, com.app.compoundinginterestproject.Yearamountadapter.class);
                    gotoyearamountadapter.putExtra("end", end);
                    gotoyearamountadapter.putExtra("noyears", noyears);
                    startActivity(gotoyearamountadapter);
                    Intent gotoactivity2 = new Intent( MainActivity.this, com.app.compoundinginterestproject.Activity2.class);
                    gotoactivity2.putExtra("end", end);
                    gotoactivity2.putExtra("noyears", noyears);
                    startActivity(gotoactivity2);

                }

            }
        });
    }

}

This is Yearamountadapter.java which extends ArrayAdapter

  TextView tvnumberofyears = (TextView) convertView.findViewById(R.id.textView1) ;
        TextView tvtotals = (TextView) convertView.findViewById(R.id.textView2);
        String years = getIntent.getStringExtra("noyears"); //could not get intent from MainActivity
        int year = Integer.parseInt(years);
        String totals = getIntent(). getStringExtra("end"); //could not get intent from MainActivity
        float total = float.parseFloat(totals);
        tvnumberofyears.setText(year);/* to get number of years increment base on the compute onclicklistener*/
        tvtotals.setText(total);/*to get the total increment bast on the compute onclicklistener*/
        return convertView;
    }
}

After I got the data from the Mainactivity, I expect the be able set the tvnumberofyears and tvtotals.setText to view in the list

Rent Charter Buses Company
READ ALSO
Cannot open Cyrillic password protected xslx file with WorkBook factory

Cannot open Cyrillic password protected xslx file with WorkBook factory

Trying to open an excel file with a password "абв" throws Exception saying the password is incorrect, although I've set the password myselfOpening a different file with the password "abc" is fine;

136
Sorting Array according to ArrayList using comparator

Sorting Array according to ArrayList using comparator

I'm trying to sort an Array (Object hits[]) that stores Objects and I need to be sorted with the exact order (asceding, descending) as in ArrayList which is already sortedThese two are not related in any way

133
How does one get Coordinates from a given address from the OpenStreetMaps API

How does one get Coordinates from a given address from the OpenStreetMaps API

So this Question might seem very trivial to some of you but bear with me please, I'm a beginner in these thingsI'm trying to make a desktop application using Java that fetches all sorts of geo information from API's that (to my knowledge) all stem from the OpenStreetMaps...

144
In Linux, does any instance of java.io.Console represent the controlling terminal of the current JVM process?

In Linux, does any instance of java.io.Console represent the controlling terminal of the current JVM process?

In Linux, a process may or may not have a controlling terminalIn Linux, does any instance of java

107