Could someone help me with this flat button design? - Java for Android App Development

. I copied
everything as he said, and I use it in xml and I can see in the preview that I have a specific design that looks close to his design
Code:
<RelativeLayout xmlns:android="htt/p://schemas.android.co/m/apk/res/android"
xmlns:fbutton="ht/tp://schemas.android.co/m/apk/res-auto"
xmlns:tools="ht/tp://schemas.android.c/om/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"
>
<info.hoang8f.widget.FButton
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|top"
android:layout_margin="10dp"
android:minHeight="@dimen/demo_button_min_height"
android:minWidth="@dimen/demo_button_min_width"
android:text="@string/buttonString"
android:textColor="@android:color/white"
fbutton:buttonColor="@color/fbutton_color_emerald"
fbutton:shadowEnabled="true" />
</RelativeLayout>
but I get this error
Code:
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\userpc\AppData\Local\Android\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output C:\Users\userpc\AndroidStudioProjects\Project\app\build\intermediates\dex\debug --input-list=C:\Users\userpc\AndroidStudioProjects\Project\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Linfo/hoang8f/widget/FButton;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
Edit: I found the problem, but I can't delete the post. I was having something extra in the gradle settings. Sorry for this post.

Please explain what extra thing you had so as to help others as well.

Related

Problem using TabActivity

Im starting to create my app, well the layout of the app. My app will consist of Tabs on the top part of the screen. Question is, how do I do that? I know its simple but yet I cant find the answer. Ive googled it, tried various methods, still errors. The TabActivity has been deprecated so I dragged the tab activity onto my layout using the palette, changed the tabs orientation to veritcal and have no idea what do from there. Ive tried the tutoirals on the developers pages by google but still no luck..
It is recommended to add them to the ActionBar.
Without your code we cannot help you. How often do we have to tell you that?
nikwen said:
It is recommended to add them to the ActionBar.
Without your code we cannot help you. How often do we have to tell you that?
Click to expand...
Click to collapse
Sorry keep on forgetting to include it.
XML:
Code:
<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=".MainActivity" >
<TabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/tab1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="@+id/tab2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="@+id/tab3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</RelativeLayout>
Theres nothing really on the class. just the default methods:
Code:
package com.examples.hello;
import android.os.Bundle;
import android.app.Activity;
public class MainActivity extends Activity {
[user=439709]@override[/user]
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
I haven't included other classes as I have tried to link them but have no idea how to so I deleted them. My minimum API level is on 8.
No problem.
However, adding tabs to the Activity is a little bit more complicated.
The way they want to do it is by using the ActionBar. There is a cool library which offers the ActionBar for old versions of Android: ActionBarSherlock.
I always do it that way: http://www.androidbegin.com/tutorial/implementing-actionbarsherlock-fragment-tabs-in-android/

[Q] not reaching onCreateOptionsMenu

I am trying to create an action bar.
I have an application with DrawerLayout that has inside a ViewPager... and I implement a PagerAadapter and a class for the page fragment.
this is the activity_main.xml under layout folder
Code:
<android.support.v4.widget.DrawerLayout
xmlns:android=<REMOVED_LINK>
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<!-- This is the main-->
<android.support.v4.view.ViewPager xmlns:android=<REMOVED_LINK>
xmlns:tools=<REMOVED_LINK>
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<!--
This title strip will display the currently visible page title, as well as the page
titles for adjacent pages.
-->
<android.support.v4.view.PagerTitleStrip
android:id="@+id/pager_title_strip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="#33b5e5"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:textColor="#fff" />
</android.support.v4.view.ViewPager>
<ListView
android:id="@+id/optionsMenu"
android:background="#000000"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
</android.support.v4.widget.DrawerLayout>
And this is the main.xml found in menu folder
Code:
<menu xmlns:android=<REMOVED_LINK>>
<item android:id="@+id/action_settings"
android:title="@string/action_settings" />
<item android:id="@+id/action_details"
android:title="@string/action_details" />
<item android:id="@+id/action_details2"
android:title="@string/action_details2" />
</menu>
The problem is that It doesn't even reach onCreateOptionsMenu on the MainActivity... I tried everything: - change android:minSdkVersion to 7, 11 and 14 (in the manifest uses-sdk tag) - add attribute to menu items "showAsAction", and remove that attribute too - make my page fragment override onCreateOptionsMenu
i debug it and it never reaches onCreateOptionsMenu, anywhere. and the getActionBar() is of course null.
Do you want it to be the native ActionBar, the ActionBarSherlock one or the ActionBarCompat one?
nikwen said:
Do you want it to be the native ActionBar, the ActionBarSherlock one or the ActionBarCompat one?
Click to expand...
Click to collapse
native ActionBar...
but as soon as I manage to reach onCreateOptionsMenu then I can do everything.
but i'm stuck on this wierd problem... maybe I should make a new project

[Q] Padding for ExpandableListView-Group

Hello,
I have a ExpandableListView and I'm using a custom layout for the groups:
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:textAppearance="?android:attr/textAppearanceListItem" >
<TextView
android:id="@+id/tvGroup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingLeft="0dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
android:textAppearance="?android:attr/textAppearanceListItem"
android:textIsSelectable="false" />
</LinearLayout>
The problem: The padding displays only right in Android 4.4, in older versions the padding is ignored..why?
The image I attached shows four different virtual devices running different Android versions.

[Q] n00b 2 Java - please help and explain

I'm trying to create a SIMPLE Grocery Shopping App. I know there are tons out there, but I'm doing this for personal use and understanding of how the system works.
Here's the XML that I have:
Code:
<RelativeLayout xmlns:android="schemas.android.com/apk/res/android"
xmlns:tools="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=".MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/itemLine"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="number"
android:ems="10"
android:hint="QTY"
android:id="@+id/qty" />
<EditText
android:id="@+id/item"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:hint="List Item"
android:layout_weight="4" />
<EditText
android:id="@+id/price"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_weight="1"
android:hint="Price"
android:ems="10"
android:inputType="numberDecimal" />
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/itemLine"
android:onClick="addItem"
android:text="Add Item" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="3"
android:text="Total with Tax:"
android:textSize="24sp" />
<TextView
android:id="@+id/totalWithTax"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1"
android:text="$0.00"
android:textSize="24sp" />
</LinearLayout>
</RelativeLayout>
My questions/problems are the following:
1. How do I have the "Add Line" button to add another line, presumably duplicate the entire LinearLayout "itemLine".
2. Calculate the running total at the bottom as items with quantities are added.
Please explain the process that the java is doing as I am a noobie to the Java coding.

Cannot Remove Battery Percentage

Hello everyone!
I have been searching about this matter for a few days now but can't seem to find a solution for it.
I am running a Samsung Galaxy S5 (SCL23)
I have a modified stock version of Android Lollipop Touchwiz 5.0.
I have already Deodexed the whole ROM.
I have successfully decompiled the whole SystemUi.apk and recompiled it without any errors.
I can change the color of the battery percentage text in the colors.xml (<color name="battery_text_color">#ffff0000</color>)
It works flawless!
But what i cannot seem to do is to remove the battery percentage completely.
I have tried adding: android:visibility="gone"
In the files: msim_system_icons.xml & system_icons.xml
Code:
<TextView android:textSize="@dimen/battery_text_size" android:textColor="@color/battery_text_color" android:layout_gravity="center" android:id="@id/battery_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:alpha="0.74" android:importantForAccessibility="no" android:fontFamily="sans-serif" android:layout_marginStart="@dimen/battery_text_marginStart" android:visibility="gone" />
But without any effect at all...
It just boots normally.
I have tried removing the "<TextView />" line completely.
But that just results in a SystemUI has stopped working on boot.
Is there anything i'm missing here?
Appreciating any kind of help!
Here is a full copy of msim_system_icons.xml & system_icons.xml
msim_system_icons.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:gravity="center_vertical" android:id="@id/system_icons" android:layout_width="wrap_content" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<com.android.keyguard.AlphaOptimizedLinearLayout android:gravity="center_vertical" android:orientation="horizontal" android:id="@id/statusIcons" android:layout_width="wrap_content" android:layout_height="fill_parent" />
<LinearLayout android:gravity="center" android:orientation="horizontal" android:id="@id/signal_battery_cluster" android:layout_width="wrap_content" android:layout_height="fill_parent" android:paddingStart="2.0dip">
<include android:id="@id/msim_signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="2.0dip" android:layout_marginEnd="@dimen/rssi_battery_gap" layout="@layout/msim_signal_cluster_view" />
<TextView android:textSize="@dimen/battery_text_size" android:textColor="@color/battery_text_color" android:layout_gravity="center" android:id="@id/battery_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:importantForAccessibility="no" android:fontFamily="sans-serif" android:layout_marginStart="@dimen/battery_text_marginStart" android:visibility="gone" />
<com.android.systemui.BatteryMeterView android:id="@id/battery" android:layout_width="@dimen/battery_icon_width" android:layout_height="@dimen/battery_icon_height" android:layout_marginBottom="@dimen/battery_icon_bottom_margin" android:layout_marginStart="3.0dip" />
</LinearLayout>
</LinearLayout>
system_icons.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:gravity="center_vertical" android:id="@id/system_icons" android:layout_width="wrap_content" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<com.android.keyguard.AlphaOptimizedLinearLayout android:gravity="center_vertical" android:orientation="horizontal" android:id="@id/statusIcons" android:layout_width="wrap_content" android:layout_height="fill_parent" android:alpha="0.74" />
<LinearLayout android:gravity="center" android:orientation="horizontal" android:id="@id/signal_battery_cluster" android:layout_width="wrap_content" android:layout_height="fill_parent" android:paddingStart="2.0dip">
<include android:id="@id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="2.0dip" android:layout_marginEnd="@dimen/rssi_battery_gap" layout="@layout/signal_cluster_view" />
<TextView android:textSize="@dimen/battery_text_size" android:textColor="@color/battery_text_color" android:layout_gravity="center" android:id="@id/battery_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:alpha="0.74" android:importantForAccessibility="no" android:fontFamily="sans-serif" android:layout_marginStart="@dimen/battery_text_marginStart" android:visibility="gone" />
<com.android.systemui.BatteryMeterView android:id="@id/battery" android:layout_width="@dimen/battery_icon_width" android:layout_height="@dimen/battery_icon_height" android:layout_marginBottom="@dimen/battery_icon_bottom_margin" android:alpha="0.74" android:layout_marginStart="3.0dip" />
</LinearLayout>
</LinearLayout>
In the latest LP firmware, there is a toggle switch in battery settings to remove the % from the status bar
*Detection* said:
In the latest LP firmware, there is a toggle switch in battery settings to remove the % from the status bar
Click to expand...
Click to collapse
Unfortunately that is not possible, since the latest update for SCL23 is LP 5.0 only.
Is it possible to add this switch by myself instead?
My idea is to locate the files that is controlling this number and just edit it away.
I'm still sitting here and fiddling with it, trying different things.
If anyone want some files from me just ask and i will post them.
I would really love to fix this, any other ideas?
It is LP 5.0 with the switch
I was thinking you could figure out what that switch changes, and add the code yourself
*Detection* said:
It is LP 5.0 with the switch
I was thinking you could figure out what that switch changes, and add the code yourself
Click to expand...
Click to collapse
I will try and look at a different ROM SystemUi and see if i can make any sense out of it.
Or maybe i will have to install The same ROM i have in a Emulator on my computer for quicker modding.
I just changed:
Dimens.xml
Code:
<dimen name="battery_text_marginStart">0.0dip</dimen>
<dimen name="battery_text_size">0.0dip</dimen>
Rebuilded.
Replaced the SystemUI, with 0644 permissions.
Also wiped Dalvik Cache & Cache.
And fixed permissions.
Restarted
To see if it will go away, i will see if it works tomorrow morning.
Its upgrading all the apps now and I've got to sleep.
Yay! That fixed it, the text is gone!

Categories

Resources