java


How to create a Sticky List Header for Contacts


I need to create a sticky list header for contacts like this
So I need some samples in github or something like this and here's the code I created If some one could help me
here's the XML FIle
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:background="#ffffff"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="mediaclub.app.paymob.AddMembersActivity">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:backgroundTint="#3cb5a4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="91"
android:orientation="horizontal"
android:weightSum="100" >
<ListView
android:id="#+id/lvContacts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
</ListView>
</LinearLayout>
</LinearLayout>
and here's the main.java
package mediaclub.app.paymob;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.widget.ImageView;
import android.widget.ListView;
import android.support.v7.widget.Toolbar;
import java.util.ArrayList;
import mediaclub.app.paymob.Adapters.ContactsAdapter;
public class AddMembersActivity extends AppCompatActivity {
ArrayList<Contact> listContacts;
ListView lvContacts;
Toolbar toolbar;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_members);
listContacts = new ContactFetcher(this).fetchAll();
lvContacts = (ListView) findViewById(R.id.lvContacts);
ImageView checkContacts = (ImageView) findViewById(R.id.checkedId);
ContactsAdapter adapterContacts = new ContactsAdapter(this, listContacts);
lvContacts.setAdapter(adapterContacts);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.iconmenu, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(android.view.MenuItem item) {
switch (item.getItemId()) {
case R.id.checkedId:
Intent i = new Intent(AddMembersActivity.this, ElShoghlActivity.class);
startActivity(i);
return true;
}
return super.onOptionsItemSelected(item);
}
}
and this is my Adapter Class
package mediaclub.app.paymob.Adapters;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import java.util.ArrayList;
import mediaclub.app.paymob.Contact;
import mediaclub.app.paymob.R;
public class ContactsAdapter extends ArrayAdapter<Contact> {
public ContactsAdapter(Context context, ArrayList<Contact> contacts) {
super(context, 0, contacts);
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
// Get the data item
Contact contact = getItem(position);
// Check if an existing view is being reused, otherwise inflate the view
View view = convertView;
if (view == null) {
LayoutInflater inflater = LayoutInflater.from(getContext());
view = inflater.inflate(R.layout.contacts_list_item, parent, false);
}
// Populate the data into the template view using the data object
CheckBox cbName = (CheckBox) view.findViewById(R.id.cbContactsId);
// ImageView pendingImage = (ImageView)view.findViewById(R.id.pendingImg);
cbName.setText(contact.name);
return view;
}
}
and here's the contact Class
package mediaclub.app.paymob;
public class ContactPhone {
public String number;
public String type;
public ContactPhone(String number, String type) {
this.number = number;
this.type = type;
}
}
and here's list view item.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:padding="3dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent" >
<RelativeLayout
android:id="#+id/menuRL"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_marginBottom="6dp">
<CheckBox
android:id="#+id/cbContactsId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="Contacts"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:layout_marginStart="34dp" />
</RelativeLayout>
</RelativeLayout>
Sorry if any thing is not Clear hope some one helps

Related Links

JavaFX backgroundImage disappearing when shrinking window
Java Threading - Wait for data to be returned, but don't block other threads
why spring boot generate jar or war file with .original extention?
Add external library .jar to Spring boot .jar /lib without mvn install
Eclipse, Maven, Antlr4: package name does not match expected package
MVC, reduce coupling between Gui and core packages
Finishing activity doesn't show previous
How to prevent the last box in a column from being editable JavaFX
/tmp/tomcat-docbase is always created with a Spring Boot JAR (but not a WAR)
Java android EventBus detect if server is send to phone message
URLClassLoader finding X but not Y in same folder
how to read from text file to labels
Java Criteria API - LowerCase a value from Database before comparing it
Most efficient way to get the highest number from a collection of integers
File.listFile() does not work properly
Difference between basic and url base64 encoding in Java 8

Categories

HOME
compiler-construction
bluetooth
debugging
proxy
jira
yarn
icloud
ebean
ravendb
onelogin
convolution
django-imagekit
mouse
metatrader4
jsdoc
normalizr
nodatime
amazonsellercentral
jquery-ajaxq
orleans
csrf-protection
tibco-mdm
format-specifiers
hammerspoon
apache-commons-io
chromebook
greendao
socialengine
binary-data
phonegap
usbserial
azure-sql-database
atl
html5-fullscreen
catalog
nssegmentedcontrol
host
ios5
space-complexity
event-driven
webdriver-manager
leading-zero
user-controls
quadratic-programming
keydown
apache-fop
brightcove
csound
snmptrapd
ifs
qtwebview
pdfclown
titanium-android
blacklist
background-service
yt-project
google-feed-api
angular-cache
vmware-tools
httplistener
yaws
bluemix-app-scan
php-parse-error
pyke
javax.sound.midi
xna-4.0
prerequisites
tmuxinator
angular-leaflet-directive
sframe
drawbitmap
tableau-online
apache-commons-fileupload
fluid-dynamics
cisco-ios
web-controls
truevault
javafx-webengine
socketexception
navigationservice
reactfx
ivyde
google-cloud-save
tws
easy-install
eclipse-memory-analyzer
django-nonrel
yui-compressor
limejs
kyotocabinet
e4x
bitsharp
gil
google-email-migration
buildr
pendrive
mercurial-server
spyware
infobox
cxxtest
sortable-tables
brewmp
xetex
signal-handling

Resources

Encrypt Message