android swipelist missing attributes - android

I have the same problem that this user : the other question
But I have the name of the class in my layout xml file correctly typed, and in the xml view it does not give any error, but when I change to graphical layout view I get an error saying :
java.lang.RuntimeException: You forgot the attributes swipeFrontView or swipeBackView.
You can add this attributes or use 'swipelist_frontview' and 'swipelist_backview'
identifiers
I added nineoldandroid and swipe-list jars.
Any tips on this?

Changing the ids in SwipeListView to
swipe:swipeBackView="#+id/swipelist_backview"
swipe:swipeFrontView="#+id/swipelist_frontview"
And in the list item view to
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="#+id/swipelist_backview"
...>
...
</RelativeLayout>
<RelativeLayout
android:id="#+id/swipelist_frontview"
...>
...
</RelativeLayout>
</FrameLayout>
Solved the problem for me. I think this bug is somehow related to this pull request https://github.com/47deg/android-swipelistview/pull/11

swipeListView have 2 views as "FrontView"&"BackView"
try this sample xml :
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:id="#+id/back"
style="#style/ListBackContent"
android:layout_width="wrap_content"
android:layout_height="110dp"
android:tag="back" >
<LinearLayout
android:id="#+id/backshowportion"
style="#style/ListBackContent"
android:layout_width="250dp"
android:layout_height="110dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:gravity="right|center" >
<TextView
.... />
<TextView
.... />
<TextView
..../>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/front"
style="#style/ListFrontContent"
android:layout_width="match_parent"
android:layout_height="110dp"
android:orientation="vertical"
android:tag="front" >
<TextView
.... />
<TextView
.... />
<TextView
.... />
</RelativeLayout>
</FrameLayout>

You need in you list something like this :
<?xml version="1.0" encoding="utf-8"?>
<com.fortysevendeg.android.swipelistview.SwipeListView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:swipe="http://schemas.android.com/apk/res-auto"
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:listSelector="#00000000"
swipe:swipeActionLeft="dismiss"
swipe:swipeBackView="#+id/back"
swipe:swipeCloseAllItemsWhenMoveList="true"
swipe:swipeFrontView="#+id/front"
swipe:swipeMode="both" />

Related

Error in xml tag </RelativeLayout> (</LinearLayout>) </ScrollView> </LinearLayout> bracketted line please solve this answer guys

<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent">
<include layout="#layout/toolbar_layout" />
<ScrollView android:background="#drawable/profpicback" android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout android:gravity="center" android:id="#id/user_update_header" android:visibility="gone" android:layout_width="fill_parent" android:layout_height="194.0dip">
<RelativeLayout android:layout_width="135.29999dip" android:layout_height="135.29999dip">
<com.mobiroller.core.views.CircleImageView android:id="#id/user_update_profile_image" android:layout_width="133.29999dip" android:layout_height="133.29999dip" app:civ_border_color="#color/white" app:civ_border_width="4.0dip" app:srcCompat="#drawable/ic_person_white_24dp" />
<com.mobiroller.core.views.CircleImageView android:id="#id/user_update_open_gallery" android:layout_width="40.0dip" android:layout_height="40.0dip" android:src="#color/black" android:layout_alignParentBottom="true" android:layout_alignParentEnd="true" app:civ_border_color="#color/black" app:civ_fill_color="#color/black" />
<RelativeLayout>
<ImageView android:id="#id/user_update_image_edit" android:padding="6.0dip" android:layout_width="40.0dip" android:layout_height="40.0dip" android:layout_alignParentBottom="true" android:layout_alignParentEnd="true" app:srcCompat="#drawable/ic_camera_alt_white_24dp" />
</RelativeLayout>
<RelativeLayout android:id="#id/user_update_form" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_below="#id/user_update_header">
<androidx.recyclerview.widget.RecyclerView android:id="#id/user_update_list" android:background="#0000ffff" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margin="13.299988dip" />
</RelativeLayout>
**</LinearLayout>**
</ScrollView>
</LinearLayout>
Having error in bold line please anyone tell solving
Every xml tag must have a closing tag.
For exmaple: Every
<RelativeLayout ...
must have a
</RelativeLayout>
tag. You are opening 4 Relative layout tags but only close 2 of it.
Btw I suggest formatting your xml for better readability.

layout_alignParentBottom not working as expected

I am trying to get a couple of buttons to attach to the bottom of the screen.
For some reason they are attaching themselves to the previous view:
As you can see the buttons are overwriting the previous view.
This is the layout I use:
<?xml version="1.0" encoding="utf-8" ?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:text_field_element="http://schemas.android.com/apk/res-auto"
xmlns:button_element="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:orientation="vertical"
>
<LinearLayout android:id="#+id/data_entry"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<com.applicat.meuchedet.views.TextFieldElement
android:id="#+id/dental_clinics_search_screen_clinic_type_selector"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
text_field_element:prompt="#string/dental_clinic_search_screen_dental_clinic_type_prompt"
text_field_element:initial_text="#string/dental_clinic_type_initial"
text_field_element:cursor_visible="false"
/>
<include
layout="#layout/separator_element"
/>
<com.applicat.meuchedet.views.LocationSelector
android:id="#+id/dental_clinics_location_selector"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<include
layout="#layout/separator_element"
/>
<com.applicat.meuchedet.views.TimeSelector
android:id="#+id/dental_clinics_time_selector"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<include
layout="#layout/separator_element"
/>
</LinearLayout>
<com.applicat.meuchedet.views.ButtonElement
android:id="#+id/dental_clinics_search_screen_search_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
button_element:margin_bottom="10"
/>
<com.applicat.meuchedet.views.ClearButtonElement
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/dental_clinics_search_screen_search_button"
android:layout_alignParentBottom="true"
button_element:margin_bottom="10"
/>
</RelativeLayout>
separator_element.xml
<?xml version="1.0" encoding="UTF-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:layout_marginBottom="15dip"
android:src="#drawable/form_separator"
>
</ImageView>
============================================================================
Edit:
So, it seems that the problem is caused by the fact that the view is put into a ScrollView. We need the ScrollView due to the possibility of small screens.
For some reason it sets the size wrong or something and puts the buttons just below the fields instead of at the very bottom.

Aligning ViewPager and TextView Vertically

<?xml version="1.0" encoding="utf-8"?>
<!-- Layout-Normal-Portrait -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/thumb_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<android.support.v4.view.ViewPager
android:id="#+id/mypager"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:layout_above="#id/sum_layout"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" >
</android.support.v4.view.ViewPager>
</RelativeLayout>
<RelativeLayout
android:id="#+id/sum_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#id/thumb_layout" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="6dp"
android:text="#string/lorem__ipsum"
android:textColor="#color/black" />
</RelativeLayout>
</RelativeLayout>
As soon as I run the program, it shows a error in the editor saying "error: Error: No resource found that matches the given name (at 'layout_above' with value '#id/sum_layout')." which is at line 22 in this code.
Can any one tell, what is wrong?
I wonder why you are making it so complex.
Anyways here is corrected snippet
<?xml version="1.0" encoding="utf-8"?>
<!-- Layout-Normal-Portrait -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" > <---No need to specify android:orientation
<android.support.v4.view.ViewPager
android:id="#+id/mypager"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#+id/textView" />
<TextView
android:id="#+id/textView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:padding="6dp"
android:text="Hello"
android:textColor="#android:color/black" /> <---Place your text String here
</RelativeLayout>
use #+id/sum_layout
and clean Project and run again!
This is because you declare sum_layout id AFTER its first reference.
The best solution is to declare it in the /res/values/ids.xml like this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item type="id" name="sum_layout" />
</resources>
And then reference it in all your layouts without the + keyword
<android.support.v4.view.ViewPager
android:layout_above="#id/sum_layout"
/>
And
<RelativeLayout android:id="#id/sum_layout" />
Try This
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/white"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
android:id="#+id/mypager"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" >
</android.support.v4.view.ViewPager>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="6dp"
android:textColor="#color/black" />
When you are using relative layout, you are relating the controls with each other.when you add any control you add next control with respect to the control defined before.Likewise here you have defined view pager layout which is under layout having id #+id/sum_layout. but you have defined layout #+id/sum_layout under view pager.so it doesn't get id #+id/sum_layout,so how it will set view pager under the text view.first of all add the view and then add to its under/above.Here is your mistake:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<android.support.v4.view.ViewPager
android:id="#+id/mypager"
android:layout_width="fill_parent"
android:layout_height="300dp">
</android.support.v4.view.ViewPager>
<TextView
android:id="#+id/mytext"
android:text="#string/lorem__ipsum"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/mypager"/>
</RelativeLayout>
Set the layout according to this wherever you have to keep to its below or above.
hope it will help you.

How to add a layout in another one?

I need to hold my every view in one layout, so that i can move them all at once... But when i tried to put them all in a layout which should be in another main layout, they cannot be seen. What am i doing wrong?
I found out that the layout called leftLayout cannot be seen. I made different colours of layouts and it showed me the main one, called menu. I tried visibility true but it didn't work as well.
My design page is like this:
It should appear like this, but i see only white window when i compile...
Here's my Xml code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/menu"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/leftLayout"
android:addStatesFromChildren="true"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="70dp"
android:orientation="vertical" >
<TextView
android:id="#+id/leftMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:enabled="true"
android:text="Left Menu"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000" />
<ListView
android:id="#+id/list"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_marginTop="70dp"
android:enabled="true" >
</ListView>
</RelativeLayout>
</RelativeLayout>
Solved! I figured out that i was just doing mistake in java codes, while setting margin. So here the code's allright.
In relative layout you always need specify the location of each child with respect to the parent or the between the children. Since you have specified the layout all the layouts will be copied one over the other. You can use child alignment options like "ABOVE", "BELOW" w.r.t to other layouts.
The below code looked like what you wanted,
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/menu"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/leftLayout"
android:addStatesFromChildren="true"
android:layout_width="100dp"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_alignleft="#+id/menu" >
<TextView
android:id="#+id/leftMenu"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:enabled="true"
android:text="Left Menu"
android:layout_weight="0"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000" />
<ListView
android:id="#+id/list"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:enabled="true"
android:layout_marginTop="50dp"
android:layout_weight="1"
android:layout_below="#+id/leftMenu" >
</ListView>
</RelativeLayout>
</RelativeLayout>
You are using a relative layout yet you have not specified the location of the child views relative to each other.
In Relative layout you must specify this, look here: http://developer.android.com/resources/tutorials/views/hello-relativelayout.html
Did you tried with LinearLayouts?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF">
<LinearLayout
android:id="#+id/leftLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="70dp"
android:orientation="vertical" >
<TextView
android:id="#+id/leftMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:enabled="true"
android:text="Left Menu"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000" />
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="70dp"
android:enabled="true" >
</ListView>
</LinearLayout>
</LinearLayout>

android viewflipper not changing view : HELP ! :)

Im having trouble to make work the viewflipper. I created a xml layout file view_flipper.xml :
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/flipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include android:id="#+id/MainView" layout="#layout/gallery_1" />
<include android:id="#+id/SearchView" layout="#layout/search_internal" />
</ViewFlipper>
the layout gallery_1 is just a ListView.
the layout search_internal has an edittext, a button, and a listview.
Im using :
ViewFlipper theFlipper=(ViewFlipper) findViewById(R.id.flipper);
theFlipper.setDisplayedChild( R.id.SearchView );
to change the layout, but its apparently work for the code, but on the display, nothing is happening... Can someone help ?
Here is the code of the layout search_internal :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/SearchBox"
>
<EditText android:text=""
android:id="#+id/QueryText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="100px"
></EditText>
<Button android:layout_height="wrap_content"
android:id="#+id/BtnOk"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"
android:text="#string/searchBtnTxt"
android:clickable="true"></Button>
</LinearLayout>
<ListView
android:id="#+id/list_view_id"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#id/SearchBox"
android:background="#FFFFFF"
android:cacheColorHint="#FFFFFF"
android:layout_marginBottom="65dip"
android:gravity="top"
/>
</RelativeLayout>
I've found that I was not using correctly the function setDisplayedChild. setDisplayedChild is zero based index apparently. Sorry.
theFlipper.setDisplayedChild( 0 );

Categories

Resources