97 views

FrameLayout fragment not visible Android

ListFragment show only one item issue

Try to change layout_width to 0dp

   <fragment android:name="cz.okhelp.android.fragchangfromlist.ArticleFragment"
              android:id="@+id/article_fragment"
              android:layout_weight="2"
              android:layout_width="0dp"
              android:layout_height="match_parent" />
<!--todo LAYOUT_WIDTH have to be 0dp !!!!!!!!!!!!!!!!!!!!! -->
 
    <FrameLayout android:id="@+id/article_fragment"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="2" />
Posted in Android Studio, Bugs, warnings, errors | Comments Off on FrameLayout fragment not visible Android
107 views

NumberFormatException Color value drawable must start with

NumberFormatException Color value drawable must start with
NumberFormatException: Color value ‘@drawable/my_picture’ must start with #

Check all colors tags if value start with#
Read this
and check path c:\Users\me\AndroidStudioProjects\myProject\myModule\build\intermediates\res\merged\debug\ values folder for corupted values or delete ALL values folders or ALL folder in debug directory
Check folders in included modules
and rebuild project

Posted in Android Studio, Bugs, warnings, errors | Tagged , | Comments Off on NumberFormatException Color value drawable must start with
118 views

Android Studio failed to convert drawable into a drawable

Try this:
– check names of drawables (file name must contain only abc…xyz 012…789 _ . in Resources folder ,
names have to start with lower case
MyImage.jpg == problem ,
names with space
my image.jpg == problem,
names with –
my-image.png == problem)
– check duplicate names with other extension ( my_image.jpg – my_image.png makes the problem)
– restart Android Studio
– if problem persist:
– check c:\Users\me\AndroidStudioProjects\myProject\myModule\build\intermediates\res\merged\debug\ drawable folder for corupted names or delete ALL drawable folders
synk projekt, rebuild projekt
– if problem persist:
– restart Android Studio, wait for complete closure of the Android Studio!

Posted in Android Studio, Bugs, warnings, errors | Tagged , | Comments Off on Android Studio failed to convert drawable into a drawable
122 views

ClassCastException fragments.MainActivity must implement OnHeadlineSelectedListener

Problem:
You have two class with similar names HeadLinesFragment and HeadMyLinesFragment with OnHeadlineSelectedListener.
Check if call correct class in MainActivity.
For example if use HeadMyLinesFragment change implement to HeadMyLinesFragment too!

public class MainActivity extends FragmentActivity 
        implements HeadLinesFragment.OnHeadlineSelectedListener { 
// wrong implements you need correct class name 
//implements  HeadMyLinesFragment.OnHeadlineSelectedListener
//............
HeadMyLinesFragment firstFragment = new HeadMyLinesFragment(); // because in code using HeadMyLinesFragment
Posted in Android Examples Code, Bugs, warnings, errors | Tagged | Comments Off on ClassCastException fragments.MainActivity must implement OnHeadlineSelectedListener
152 views

Who has higher priority build.gradle or AndroidManifest Android Studio

build.gradle in module have higher priority then AndrodiManifest.xml
Try this.
AndroidManifest.xml have code:

    <uses-sdk
        android:minSdkVersion="9"
        android:targetSdkVersion="23" />

build.gradle have code:

   defaultConfig {
        applicationId "cz.okhelp.words"
        minSdkVersion 9
        targetSdkVersion 19
        versionCode 107
        versionName "1.0.7"
    }

Warning in AndroidManifest.xml:
This targetSdkVersion value (23) is not used; it is always overridden by the value specified in the Gradle build script (19) less... (Ctrl+F1)
The value of (for example) minSdkVersion is only used if it is not specified in the build.gradle build scripts. When specified in the Gradle build scripts, the manifest value is ignored and can be misleading, so should be removed to avoid ambiguity.

Posted in Android Studio, Bugs, warnings, errors | Tagged | Comments Off on Who has higher priority build.gradle or AndroidManifest Android Studio
145 views

View getId is null Android

If you create a button or view programmatically with OnClickListener you can set a tag key before button in parent layout is added.
And get correct button by this tag getTag() instead getId() in OnClickListener etc.

Button button = new Button(getApplicationContext());
int idOfButton = button.getId(); // return -1
 
button.setTag("my_button");
String sTag = (String) button.getTag(); // return "my_button"
Posted in Android Examples Code | Tagged , | Comments Off on View getId is null Android
119 views

Words CZ Vyjmenovaná slova jako test paměti

Aplikace umožňuje procvičovat jak vyjmenovaná slova, tak i trénovat paměť. Download na tomto odkaze.
Náhodná slova se ukáží zhruba na 15 sekund.
Vašim úkolem je určit, které slovo nebylo zobrazeno na seznamu kliknutím na určité tlačítko.
V seznamu jsou i slova podobná pravopisem, ale mající jiný význam. Ta jsou označena hvězdičkou * a píšeme v nich měkké i.

Posted in Android Software Download | Tagged , | Comments Off on Words CZ Vyjmenovaná slova jako test paměti
162 views

App have transparent menu Android

If the app have transparent menu and you do not want this,
try delete @style/AppTheme in application tag in AndroidManifest.xml
and try run module – project. If menu is not transparent , maybe it caused

 <application
        android:allowBackup="true"
        android:icon="@drawable/dicts_ico"
        android:label="@string/app_name" 
        android:theme="@style/AppTheme" // delete this row - run app - try menu
 >

Or try set values\styles.xml into basic Theme

<resources>
 
    <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
    -->
    <style name="AppBaseTheme" parent="android:Theme.Black">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
    </style>
 
    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    </style>
 
</resources>
Posted in Android Examples Code, Android Studio, Bugs, warnings, errors | Tagged | Comments Off on App have transparent menu Android
173 views

layout-sw600dp values-sw600dp Android example of use

Why the app selects data from basic layout folder if smallest width is higher then the number in folder name?
Example 1
layout-sw600dp values-sw600dp (smallest width sw for data usage from this folder is 600dp density independent pixel!!!!!)
Device screen resolution is 1200 x 900 px (pixel) Wow, app to be select data from sw600dp folder! Realy?
DPI of device screen – dot per inch (pixel per inch) is 480 pixel it is wery important number!

  1. App selects smallest dimension of screen. In our case 900 px
    Medium screen have 160 dpi (The density-independent pixel is equivalent to one physical pixel on a 160 dpi screen, which is the baseline density assumed by the system for a “medium” density screen.).
  2. App calculate ratio 480 / 160 = 3 (The conversion of dp units to screen pixels: px = dp * (dpi / 160))
  3. App calculate smallest dimesnion of screen in dp 900 / 3 = 300 dip or dp (density independed pixel).
  4. App selects data from basic values and layout folder because sw600dp is greater than 300dp.

In our case smallest dimension of screen must be at least 1800 real – physical pixels (1800 px / 3 ratio(dpi/160) = 600 dp (dip density independend pixels) to be used data from folders values-sw600dp and layout-sw600dp.

Example 2 see Example 1 abouve
Device: Nexus 7 (2012) selected from Android Studio tool layout editor
Resolution: 800×1280 px
DPI: tvdpi (approximately 213dpi)
Ratio: 1.33 (213 / 160)
Smallest width in px: 800
Convert px to dp: 601.5 (800 / 1.33)
Result:Smallest width is 601.5dp The App to be used data from folders values-sw600dp and layout-sw600dp.

Posted in Android Examples Code | Tagged | Comments Off on layout-sw600dp values-sw600dp Android example of use
165 views

Center View in RelativeLayout Android

RelativeLayout like parent, child Srollview is centered horizontal.
Second RelativeLayout in SrollView have gravity center, every child will centered horizontally and vertically.

<?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="match_parent"
    android:gravity="center_horizontal">
 
    <ScrollView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/scrollView2" >
 
        <RelativeLayout
            android:layout_width="320dp"
            android:layout_height="wrap_content"
            android:background="#e6f825"
            android:gravity="center">
 
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="New Button"
                android:id="@+id/button" />
        </RelativeLayout>
    </ScrollView>
 
</RelativeLayout>
Posted in Android Examples Code | Tagged | Comments Off on Center View in RelativeLayout Android
165 views