Tag: xml

How to programmatically reference <string> in xml file in android

I am new to android programming and wanna know this: I have 3 strings defined in the strings.xml file: <resources> <string name=”one”>First Click </string> <string name=”two”>Second Click </string> <string name=”three”>Third Click </string> <resources> and a text view which displays the first string in the strings.xml file. i don’t want to use settext(“******”) to change the […]

Android Background Image in XML File

I currently have an application which has the default black background for every slide. What I would like to do is alter the XML files to have a background image. I’m assuming there is a simple command for this but haven’t been able to find exactly what I’m looking for. I want an image to […]

Drawable resource from custom attribute

Is there any possibility to get resource from drawable folder right in some custom attribute, so i can write: <com.my.custom.View android:layout_height=”50dp” android:layout_width=”50dp” … my_custom:drawableSomewhere=”@drawable/some_image” /> and then simple perform action with drawable inside my custom view class?

String types not allowed (at 'id' with value ' @id/bAdd')

I am getting an error saying String types not allowed (at ‘id’ with value ‘ @id/bAdd’) I’ve cleaned the project. Everything was working earlier, I don’t what happened, causing this error. <LinearLayout 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” android:orientation=”vertical” > <TextView android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:layout_centerHorizontal=”true” android:layout_centerVertical=”true” android:text=”Your total is 0″ android:textSize=”45dp” android:layout_gravity=”center” android:gravity=”center” android:id=”@+id/tvDisplay” tools:context=”.StartingPoint” /> <Button android:layout_width=”250dp” […]

border of items of listview in android

I want to set border of Edittext and items of listview as in the picture : My xml code is as following : <LinearLayout android:background=”#BDD6E0″ android:layout_height=”wrap_content” android:layout_width=”match_parent” android:orientation=”vertical” > </LinearLayout> <LinearLayout android:background=”#BDD6E0″ android:layout_height=”wrap_content” android:layout_width=”match_parent” android:orientation=”vertical” > <TextView android:id=”@+id/textView1″ android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_weight=”1″ android:text=”Search” android:textColor=”#000000″ android:background=”#FFFFFF” android:textAppearance=”?android:attr/textAppearanceLarge” /> <EditText android:id=”@+id/search_pat_edit” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:singleLine=”true” android:textColor=”#000000″ android:layout_weight=”4″> </EditText> </LinearLayout> […]

android:capitalize not working

I have a TextView. I’m trying to capitalize the first letter in every word. Here’s the TextView: <TextView android:text=”TextView” android:id=”@+id/textView1″ android:layout_height=”wrap_content” android:layout_width=”wrap_content” android:layout_alignParentRight=”true” android:textSize=”30dip” android:textStyle=”bold” android:layout_marginRight=”5dip” android:ellipsize=”end” android:capitalize=”words”> </TextView> Here’s how I’m adding the text: TextView titleView = (TextView) findViewById(R.id.textView1); titleView.setText( section.replace(“_”, ” “) ); Can I not add text dynamically and expect it to […]

Error while trying to test AnimatedVectorDrawable, “Can't morph from x to z”

I wanted to make an AnimatedVectorDrawable, so that my FAB can look atleast somewhat as fabulous as this one, with animations and stuff. I found this great tutorial, on how to use & implement them etc, and later on I found a very usefull tool for converting SVG’s into Android-VectorDrawables, and converted these two images: […]

Programatically set '?selectableItemBackground' on Android view

In xml, I often do this to emulate onClick effect: <android.support.v7.widget.CardView android:id=”@+id/cardView” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:foreground=”?selectableItemBackground”> … </android.support.v7.widget.CardView> Is there any way to access ?selectableItemBackground in java?

Could not initialize LoginButton Facebook-sdk for android

im working on an android project an i want to put a Facebook Login feature, i added the Facebook sdk Correctly but i could not initialize LoginButton **java.lang.NoClassDefFoundError: Could not initialize class com.facebook.login.widget.LoginButton** at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:413) at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105) at com.android.tools.idea.rendering.LayoutlibCallback.loadView(LayoutlibCallback.java:176) at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207) at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:132) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:806) at […]

Android manifest attribute not allowed here

I have several manifest errors regarding some attributes . I have not made any changes to the manifest the application generated automatically yet i get several errors. *( I’m using Android Studio 1.2.2) <?xml version=”1.0″ encoding=”utf-8″?> <manifest xmlns:android=”http://schemas.android.com/apk/res/android” package=”com.example.iustinian.girlfriendsolver” android:versionCode=”1″ android:versionName=”1.0″ > <uses-sdk android:minSdkVersion=”14″ android:targetSdkVersion=”22″ /> <application android:allowBackup=”true” android:icon=”@mipmap/ic_launcher” android:label=”@string/app_name” android:theme=”@style/AppTheme” > <activity android:name=”com.example.iustinian.girlfriendsolver.MainActivity” android:label=”@string/app_name” […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.