Just one row in my listview should be sticky .Not sections or section with alphabets in stickyheaders.I really appreciate any help w.r.t listview sticky one row within activity
I wrote this code for Json... Hope this will solve your puzzle.. And you like this...
public class MainActivity extends Activity {
private ArrayList data;
private TextView stickRow;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
stickRow = (TextView) findViewById(R.id.headerRow);
data = new ArrayList();
for (int ak = 1; ak < 20; ak++) {
data.add("Row " + ak);
}
ListView lv = (ListView) findViewById(R.id.listView1);
lv.setAdapter(new CustomAdapter(getApplicationContext(), R.layout.activity_main));
}
class CustomAdapter extends ArrayAdapter {
public CustomAdapter(Context context, int resource) {
super(context, resource);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
if (position == 0) {
stickRow.setText(getItem(position));
}
TextView tv = new TextView(getApplicationContext());
tv.setTextSize(20);
tv.setText(getItem(position + 1));
return tv;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return data.size() - 1;
}
@Override
public String getItem(int position) {
// TODO Auto-generated method stub
return data.get(position);
}
}
}