ListView listView = findViewById(R.id.list_view); View footerView = getLayoutInflater().inflate(R.layout.footer_view, null); listView.addFooterView(footerView); //... listView.removeFooterView(footerView);
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ListView listView = (ListView) findViewById(R.id.list_view); // Set the adapter for the ListView ArrayAdapterIn this example, an adapter is created and set as the data source for the `ListView`. A footer view is then added to the `ListView`. A `Handler` is used to schedule the removal of the footer view after 5 seconds. The `android.widget` package library contains the `ListView` widget, along with other UI elements such as `TextView`, `ImageView`, `Button`, and `EditText`.adapter = new ArrayAdapter (this, android.R.layout.simple_list_item_1, android.R.id.text1, values); listView.setAdapter(adapter); // Add a footer view TextView footerView = new TextView(this); footerView.setText("This is a footer view"); listView.addFooterView(footerView); // Remove the footer view after 5 seconds Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { listView.removeFooterView(footerView); } }, 5000); }