Open diegoisaac2086 opened 7 months ago
import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.ArrayAdapter; import android.widget.ListView;
public class MainActivity extends AppCompatActivity {
private ListView menuListView;
private ListView pricesListView;
private String[] menuItems = {"Empanada de carne", "Empanada de pollo", "Empanada de jamón y queso"};
private double[] prices = {2.50, 2.00, 2.75};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
menuListView = findViewById(R.id.menuListView);
pricesListView = findViewById(R.id.pricesListView);
ArrayAdapter<String> menuAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, menuItems);
ArrayAdapter<String> pricesAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, getPriceList());
menuListView.setAdapter(menuAdapter);
pricesListView.setAdapter(pricesAdapter);
}
private String[] getPriceList() {
String[] priceList = new String[menuItems.length];
for (int i = 0; i < menuItems.length; i++) {
priceList[i] = "$" + prices[i];
}
return priceList;
}
}import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.ArrayAdapter; import android.widget.ListView;
public class MainActivity extends AppCompatActivity {
private ListView menuListView;
private ListView pricesListView;
private String[] menuItems = {"Empanada de carne", "Empanada de pollo", "Empanada de jamón y queso"};
private double[] prices = {2.50, 2.00, 2.75};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
menuListView = findViewById(R.id.menuListView);
pricesListView = findViewById(R.id.pricesListView);
ArrayAdapter<String> menuAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, menuItems);
ArrayAdapter<String> pricesAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, getPriceList());
menuListView.setAdapter(menuAdapter);
pricesListView.setAdapter(pricesAdapter);
}
private String[] getPriceList() {
String[] priceList = new String[menuItems.length];
for (int i = 0; i < menuItems.length; i++) {
priceList[i] = "$" + prices[i];
}
return priceList;
}
}
<!DOCTYPE html>
Menú de Comidas