I used SwipeMenuListView from github It works but Views are not consistent as in the picture
Activity layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.robo.lolita.swipemenurecyclerview.MainActivity">
<com.baoyz.swipemenulistview.SwipeMenuListView
android:id="#+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
this is simple layout swipe menu layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent" android:background="#android:color/holo_blue_bright">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/count"/>
</LinearLayout>
SwipeMenuCreator creator = new SwipeMenuCreator() {
public void create(SwipeMenu menu) {
SwipeMenuItem deleteItem = new SwipeMenuItem(
getApplicationContext());
deleteItem.setBackground(new ColorDrawable(Color.rgb(0xF9,
0x3F, 0x25)));
deleteItem.setWidth(dp2px(90));
deleteItem.setIcon(R.drawable.camera_icn);
menu.addMenuItem(deleteItem);
I need to attach delete button to the item of listview on Swipe. this swipe menu with delete button. i want to delete the item on clicking the delete button but views are inconsistent in swipemenulistview. Any help to acheive this. Well i cannot do swipe to dismiss and i know we should not mimic the UI of other platforms. but this is the requirement .
Related
now I just got listview in android layout now i want to add cardview to this to show list of cardview.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/clistview">
</ListView>
</LinearLayout>
//java code
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(ActivityCourseListView.this, android.R.layout.simple_list_item_1,adapterlist);
clistview.setAdapter(adapter);
Log.e("Course ListView","Courses"+adapterlist);
You can't do this with a normal list view. You have to use a custom listview for this. Here is a tutorial
https://www.youtube.com/watch?v=By_1tpPDt4g
I have added the ListView inside ViewPager, as soon as the page is loaded the first tab is selected and the last item of the list does not show up for the first time, its becoming visible when I go to next tab and come back. I would like to see all the items of the listview when its loaded for the first time. Please help me to fix this problem.
This is the xml for the listview -
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#+id/listview_categories"
android:layout_width="fill_parent"
android:divider="#color/light_gray_a1"
android:dividerHeight="0.667dp"
android:background="#color/white"
android:layout_height="fill_parent" />
</RelativeLayout>
add bottom padding like this and change fill_parent to match_parent
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#+id/listview_categories"
android:layout_width="match_parent"
android:divider="#color/light_gray_a1"
android:dividerHeight="0.667dp"
android:paddingBottom="40dp"
android:background="#color/white"
android:layout_height="match_parent" />
</RelativeLayout>
I had this issue. Just now I solved it. Look for android:layout_weight in all the Layouts you used and if it is set some non zero values like android:layout_weight="1" or android:layout_weight="0.91", then set them to zero like this,
android:layout_weight="0"
I have a very simple listview, but now it shoes all empty when open it, I wanna user see the light grey lines in this empty list view to let them know this is something will list, Is there any way to show the lines when the listview still empty please?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.anna.DiscoverActivity">
<android.support.v7.widget.SearchView
android:id="#+id/searchview"
app:queryHint="Search HoodMark"
android:background="#color/colorAccent"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<ListView
android:layout_below="#id/searchview"
android:id="#+id/discover_list"
android:divider="#color/colorAccent"
android:dividerHeight="4px"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
</RelativeLayout>`
Yes there is. Create an emptyView, design it as you like then supply it to the your adapter. Like this:
//inflate your empty view
View emptyView=getLayoutInflater().inflate(R.layout.emptyViewLayout,null,false);
//set to your listView
listView.setEmptyView(emptyView);
I have an application in which I am using a list view
setListAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_activated_1,titles));
now what I get is like this
as you can see when I press on the text it senses it and not anywhere on the row beyond that.Is there any way I can work this thing out other than using my custom xml file(resource) for list.
Xml
<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="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MovieCritics" >
<fragment class="com.example.moviecritics.FragmentMovieName"
android:id="#+id/movie_name"
android:name="android.support.v4.app.ListFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
and it's working fine in landscape mode
Try android:listSelector in your ListView
was trying the drawer layout example mentioned in here
After trying this out, I added a few elements, like a button, to the main layout. This is what I did :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin" >
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:onClick="openTestButtonActivity"
android:text="#string/testing" />
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
.
.
.
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
Now, the drawer works good, but I am not able to activate my button. Is there anything in the ordering of layouts that I am doing wrong ?
Yes, layout order is wrong. In relativeLayout views are ordered like are added in code. So if you add button first and then you add drawerLayout, drawerLayout overlays button. So you should add DrawerLayout first and then Button.