greenfablab

GreenFabLab Android App
Log | Files | Refs

ExhibitList.java (1310B)


      1 package space.nocebo.myapplication;
      2 
      3 import android.content.Intent;
      4 import android.os.Bundle;
      5 import android.view.View;
      6 import android.widget.AdapterView;
      7 import android.widget.ArrayAdapter;
      8 import android.widget.ListView;
      9 
     10 import java.util.EventListener;
     11 
     12 import androidx.appcompat.app.AppCompatActivity;
     13 
     14 public class ExhibitList extends AppCompatActivity {
     15     private String[] exhibits = new String[50];
     16 
     17     private void setExhibits() {
     18         for (int i = 0; i < 50; i++) {
     19             exhibits[i] = "Exhibit " + i;
     20         }
     21     }
     22 
     23     @Override
     24     protected void onCreate(Bundle savedInstanceState) {
     25         super.onCreate(savedInstanceState);
     26         setContentView(R.layout.activity_exhibitlist);
     27         setExhibits();
     28 
     29         ArrayAdapter adapter = new ArrayAdapter<String>(this,
     30                 R.layout.activity_listitem_1, exhibits);
     31 
     32         ListView listView = (ListView) findViewById(R.id.ExhibitList);
     33         listView.setAdapter(adapter);
     34         listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
     35             @Override
     36             public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
     37                 Intent intent = new Intent(ExhibitList.this, Exhibit.class);
     38                 startActivity(intent);
     39             }
     40         });
     41     }
     42 }