Как устранить следующую ошибку Продукт() в Продукт нельзя применить?
Здесь я объявил переменные класса продукта и назначил его.
product.java
public class Product {
String[] name= new String[100];
int price;
int image;
boolean box;
Product(String[] _describe, int _price, int _image, boolean _box) {
name = _describe;
price = _price;
image = _image;
box = _box;
}
}
Это мой класс продукта. Что я должен изменить в приведенном выше коде? Открытый класс MainActivity extends Activity { String [] data = new String [] {"no: 1", "no: 2", "no: 3", "no: 4", "no: 5", "no : 6" }; String [] columnTags = new String [] {"ProcessName", "IpItem", "IpColor", "OpItem", "OpColor", "PlanQty", "DcQty", "RecQty", "RtQty"}; ArrayList products = new ArrayList(); ListAdapter1 boxAdapter;
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
fillData();
boxAdapter = new ListAdapter1(this, products);
ListView lvMain = (ListView) findViewById(R.id.lvMain);
lvMain.setAdapter(boxAdapter);
}
void fillData() {
for (int i = 0; i <= 20; i++) {
products.add(new Product(columnTags, i * 100,i * 553
, false));
}
}
public void showResult(View v) {
String result = "Selected Product are :";
int totalAmount=0;
for (Product p : boxAdapter.getBox()) {
if (p.box){
result += "\n" + p.name;
totalAmount+=p.image;
}
}
String total="Total="+totalAmount;
// Toast.makeText(this, result+"\n"+"Total Amount:="+totalAmount, Toast.LENGTH_LONG).show();
Bundle bundle=new Bundle();
bundle.putString("res",result);
bundle.putString("tot",total);
Intent intent = new Intent(MainActivity.this,MainActivity2Activity.class);
intent.putExtras(bundle);
startActivity(intent);
}
}
Опубликовать связанный код ... изображение не помогает читать код ... – johnrao07
Ваш код отличается своим изображением. И ваш код прав. –