Example 1: flutter listview
ListView(
padding: const EdgeInsets.all(8),
children: [
Container(
height: 50,
color: Colors.amber[600],
child: const Center(child: Text('Entry A')),
),
Container(
height: 50,
color: Colors.amber[500],
child: const Center(child: Text('Entry B')),
),
Container(
height: 50,
color: Colors.amber[100],
child: const Center(child: Text('Entry C')),
),
],
)
Example 2: listview in android
Android ListView is a view which groups several items and display them in vertical scrollable list. The list items are automatically inserted to the list using an Adapter that pulls content from a source such as an array or database.
Example 3: how to create list in android '
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.MotionEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.Toast;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ListView list = findViewById(R.id.list);
ArrayList arrayList = new ArrayList<>();
arrayList.add("JAVA");
arrayList.add("ANDROID");
arrayList.add("C Language");
arrayList.add("CPP Language");
arrayList.add("Go Language");
arrayList.add("AVN SYSTEMS");
ArrayAdapter arrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, arrayList);
list.setAdapter(arrayAdapter);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView> parent, View view, int position, long id) {
String clickedItem=(String) list.getItemAtPosition(position);
Toast.makeText(MainActivity.this,clickedItem,Toast.LENGTH_LONG).show();
}
});
}
}
Example 4: android java list view
ListView friendsListView = findViewById(R.id.friendListView);
final ArrayList myFriends = new ArrayList(asList("Mark","Jane","Sussy","Jan"));
ArrayAdapter arrayAdapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1, myFriends);
friendsListView.setAdapter(arrayAdapter); // Set an adapter
friendsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView> adapterView, View view, int i, long l) {
Toast.makeText(getApplicationContext(), "Hello " + myFriends.get(i), Toast.LENGTH_LONG).show();
Example 5: listview
class YourView(ListView):
model = YourModel
paginate_by = your_pagination_number
context_object_name = 'your_model_in_plural'
template_name = 'your_list.html'