android


Custom Listview : span listitems on selection


First of all I apologize for not posting any code on what I have done.But I am not getting the point from where and how to start customize listview.
Question :
I have to create a listview in which based on the selection adjacent listitems shall merge.
I googled but couldn't find any relevant information.
Please help me.
Please see the attached image.
See this image..it shows rounded corner background of listitems
Default list is the list with some custom adapter and second image shows what is expected.
It is bit tricky but i think the best possible solution for this problem is listView inside a listView.
Now let me explain,
There should be two list view
LV1 (ExtendedHeightListView) : It will have height equal to the height of all items (obviously view will not recycle in this listview). We will use it as a item for main list view.
public class ExtendedHeightListView extends ListView {
boolean expanded = false;
public ExtendedHeightListView(Context context) {
super(context);
}
public ExtendedHeightListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ExtendedHeightListView(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
}
public boolean isExpanded() {
return expanded;
}
public void setExpanded(boolean expanded) {
this.expanded = expanded;
}
#Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (isExpanded()) {
// Calculate entire height by providing a very large height hint.
// But do not use the highest 2 bits of this integer; those are
// reserved for the MeasureSpec mode.
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
android.view.ViewGroup.LayoutParams params = getLayoutParams();
params.height = getMeasuredHeight();
} else {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
}
LV2 (Default ListView) : Main ListView have items as extended height list view. (It is normal list view so your small list views will recycle).
Now considering you have data in grouped manner. Say
G1 - 2 items,
G2 - 5 items,
G3 - 1 item
BaseAdapter(BA1) for ExtendedHeightListView (LV1) :
public void BA1(Context context, Grp g) {
this.context = context;
this.grp = g;
}
public int getCount() {
return grp.getNumberOfItems();
}
public View getView(int position, ... ) {
// write here your normal getView;
}
BaseAdapter(BA2) for Main ListView (LV2) :
pass G1, G2 and G3 to the adapter.
public int getCount() {
return 3; //Number of groups
}
public View getView (int position, ... ) {
if (convertView == null) {
convertView = inflate LV1;
}
ExtendedHeightListView lv1 = convertView.findViewById(R.id.lv1);
Grp g = getGroup(position);
BA1 adapter = new BA1 (context, g);
//If background of each group is different
lv1.setBackgroundResource(R.drawable.bg);
lv1.setAdapter (adapter);
return convertView;
}
And set your OnItemClickListener on Main ListView (LV2).
I think it will help...

Related Links

“Android Design Icons” do not match system icons
Translucent one time startup activity
Removing Border from ListView
I want 1 Spinner dependent on another spinner item
Android Error: Binary XML file line #16: Error inflating class fragment when adding map fragment
phonegap android datepicker plugin not working on second field
remove the Video view's Seekbar in android
You uploaded an APK that is signed with a different certificate to your previous APKs [duplicate]
Wrap include around views [closed]
how to link face detector api with the photo activity
How to create a customized Soft keyboard with my own set of images
How to get connected device count in hotspot(AP) programmatically [Android]
Android project in Eclipse is missing the Android 4.2.2 library folder
Phonegap Android InAppBrowser not working
Failed to load map. Error contacting Google servers on fragment
String questionText=“Hello good evenin${b}${u} Amit is the best ${/u}${/b} and he loves singing”; [closed]

Categories

HOME
shell
sonarqube
notepad++
cygwin
httparty
fabricjs
phpword
google-cloud-platform
jpa
checkstyle
string
telegram
css3
depth
pyqt
rsa
oracle-apex-5
carousel
jetty
python-multithreading
google-cloud-datalab
gluon-mobile
webix
enthought
libc
stellar.js
screen-readers
soci
symbols
libigl
hta
direct3d11
fable-f#
jasmine-node
fractions
winexe
quantlib
mql
vex
userdefaults
kudu
paragraph
git-squash
wacom
instantiation
installshield-le
sendbird
indy10
reverse
mnist
protege4
android-augmented-reality
release
z-notation
health-monitoring
magento-1.9.3
apriori
lpsolve
knime
xbmc
textsum
launchctl
lightning
carrot2
magic-draw
stdmap
arules
dt
er-diagram
cronexpression
slackware
hadoop-2.7.2
windows-azure-queues
x-tag
vorpal.js
refinerycms
createprocess
lz77
exim4
dynamics-nav-2016
sciruby
pypiserver
.bash-profile
dronekit-android
dot.js
broadband
procedural-programming
mass-assignment
android-cookiemanager
jbake
wcm
mdichild
matrix-inverse
wxformbuilder
sbcl
bin
hibernate-entitymanager
embedded-fonts
node-blade
joomla-template
onload-event
wp7test
insert-id
web-notifications
dopostback
monotouch.dialog
entitydatasource
tournament
qglwidget
cac
openfaces
django-piston
lalr
dsl-tools
firefox-3
flvplayback
unmanagedresources
technical-debt
pbcopy
appliance

Resources

Encrypt Message