My findViewById is not working. in my fragment - kotlin

My findViewById is not working. it does not link...
////my fragment.contacts.xml
*<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<EditText
android:id="#+id/txtShowOnMap"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:contentDescription="#string/locationonmap"
android:importantForAutofill="no"
android:inputType="text"
android:labelFor="#id/btnShowOnMap"
android:minHeight="48dp"
android:text="#string/store_location" />
<Button
android:id="#+id/btnShowOnMap"
android:layout_width="395dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:text="#string/map" />
</LinearLayout>*
////end of fragmentcontacts.xml
my contactsfragment.kt

Please Make it view.findViewById
For fragment you need to add rootview.

Related

How to scroll recyclerview with Image or ImageSlider

Please help me.
I can't scroll image with recyclerview.
XML:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="#drawable/pattern"
android:orientation="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="#layout/app_bar_main">
<ImageView
android:layout_width="match_parent"
android:layout_height="200dp"
android:src="#drawable/line" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/main_swipe"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="#+id/rc"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
//Have a bit of a problem with the ImageView
//ScrollView but not working.
You can use linearlayout's layout weight:
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/main_swipe"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
>
<android.support.v7.widget.RecyclerView
android:id="#+id/rc"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
/>
</android.support.v4.widget.SwipeRefreshLayout>

transition not working in AppBarLayout android

I have RecyclerView with the following layout for items:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:background="?android:attr/selectableItemBackground"
android:gravity="center">
<LinearLayout
android:id="#+id/name_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:transitionName="#string/transition_name_details">
<TextView
android:id="#+id/name"
style="#style/input_text_style"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:textColor="#color/primaryTextColor"/>
</LinearLayout>
When clicked on an item an activity is shown with the following layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="15dp"
android:clipToPadding="false"
android:paddingBottom="80dp"
android:scrollbars="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior"/>
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
app:elevation="0dp">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="15dp"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:transitionName="#string/transition_name_details">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="#+id/name"
style="#style/input_text_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/name"
android:imeOptions="actionDone"
android:inputType="text"
android:maxLines="1"
/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>...
Unfortunately the value of the TextInputEditText is not showing when the second activity is displayed. But when I click on the TextInputEditText the value is then displayed.
Changing the first layout to this one solved the problem:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/name_layout"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:background="?android:attr/selectableItemBackground"
android:gravity="center"
android:transitionName="#string/transition_name_details">
<TextView
android:id="#+id/name"
style="#style/input_text_style"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:textColor="#color/primaryTextColor"/>
</RelativeLayout>

Floating action button with CoordinatorLayout

I using fragments in my app. I have base activity with hiding toolbar when content is scrolling. But is not working with this fragment. FAB is hiding ok but toolbar is not hiding when i scrolling. FAB and list not fitting bottom. How to do that? Thx.
Sorry for my English please.
Activity layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.CoordinatorLayout
android:id="#+id/coordinator"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.AppBarLayout
android:id="#+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="#style/AppTheme.AppBarOverlay"
app:elevation="0dp">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|enterAlways">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="0dp"
app:layout_collapseMode="pin"
app:popupTheme="#style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="#layout/app_nav_header_main"
app:menu="#menu/main_drawer" />
</android.support.v4.widget.DrawerLayout>
Fragment layout:
<?xml version="1.0" encoding="utf-8"?>
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/flipper"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="#layout/layout_please_wait"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.CoordinatorLayout
android:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/refresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp">
<android.support.v7.widget.RecyclerView
android:id="#+id/adsList"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/addAds"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:src="#drawable/ic_action_new"
app:layout_anchor="#id/adsList"
app:layout_anchorGravity="bottom|right|end"
app:layout_behavior="sakh.com.utils.ScrollAwareFABBehavior"
app:useCompatPadding="true" />
</android.support.design.widget.CoordinatorLayout>
<include
layout="#layout/layout_no_internet"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<include
layout="#layout/layout_no_search_result"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</ViewFlipper>

material design not working samsung S7

I just released my app using Material design patterns, am essentially using the out of box DrawerLayout/Nav and CardView/RecyclerView.
Here's the App if you want to try: https://play.google.com/store/apps/details?id=com.cp2.start.and.play.music.player , Works on all my devices but users report on Samsung S7 not so much
Here's the definitions:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/allotherelements"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".MainCardActivity"
tools:showIn="#layout/app_bar_main_card">
<android.support.v7.widget.RecyclerView
android:id="#+id/device_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:layout_below="#+id/textView2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
Than insert Cards using:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:animateLayoutChanges="true"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="#+id/card_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
card_view:cardCornerRadius="4dp"
android:layout_margin="3dp"
card_view:contentPadding="5dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_toLeftOf="#+id/imageButton"
android:layout_toStartOf="#+id/imageButton">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New CheckBox"
android:id="#+id/checkBox" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:focusableInTouchMode="false">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Volume"
android:id="#+id/volumeText"
android:layout_marginBottom="5dp"
android:layout_marginTop="10dp" />
<SeekBar
android:id="#+id/volumeslider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:max="15"
android:layout_marginTop="10dp" />
</LinearLayout>
</LinearLayout>
<ImageButton
android:id="#+id/imageButton"
android:layout_width="52dp"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:background="#android:color/background_light"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
The Adapter and and all are working fine on my Nexus 5, and OLD Asus tablet(on android 4.3).
My user reported an empty screen. Has anyone heard of Samsung 7 having issues with RecyclerView or CardView

PreferenceFragment - how to remove line between items?

How can I remove the horizontal line below the fields(red)?
Also i want to know, how i can insert an horizontal line between the categories(blue)?
settings.xml
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory
android:title="#string/pref_ankunft_abflug"
android:layout="#layout/styles1">
<com.example.world.DatePickerPreference
android:key="prefVon"
android:layout="#layout/styles1"
android:summary="#string/pref_datum_von" />
<com.example.world.DatePickerPreference
android:key="prefBis"
android:layout="#layout/styles1"
android:summary="#string/pref_datum_bis"/>
<com.example.world.DatePickerPreference
android:key="prefBis"
android:layout="#layout/styles1"
android:summary="#string/pref_datum_bis"/>
</PreferenceCategory>
<PreferenceCategory>
<Preference
android:layout_width="fill_parent"
android:layout_height="5dip"
android:background="#color/texte" />
<ListPreference
android:defaultValue="10"
android:entries="#array/Vorschläge"
android:entryValues="#array/VorschlägeValues"
android:key="prefUmkreis"
android:layout="#layout/styles1"
android:summary="#string/pref_umkreis_titel"
android:title="#string/pref_umkreis"/>
</PreferenceCategory>
</PreferenceScreen>
styles1.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="#+android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:layout_marginLeft="20dp"
android:textSize="21sp"
android:textStyle="bold"
android:textColor="#color/ueberschrift"/>
<TextView android:id="#+android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="21sp"
android:layout_marginLeft="20dp"
android:textColor="#color/texte"/>
</LinearLayout>
Picture:
http://www.directupload.net/file/d/3629/h4kczzxv_png.htm