i have some doubts related to view flipper in android
1>when to use setAnimation and setInAnimation/setOutAnimation? or what the difference between them?
2>can u decipher push_left_in.xml in animation folder(available in sample folder in sdk) as i have to make push_right_in.xml ?
HTML:
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="100%p" android:toXDelta="0" android:duration="300"/>
<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="300" />
</set>
I've just started developing my first app a couple weeks ago, I learned coding in flash and with HTML(not 5).
I'm developing an aggregator app to help you check stuff on your device faster.
I am completly stuck on the simpliest thing, I need to know how to properly add @string's to my XML for buttons, etc. and how to add to the strings file so I dont get those warnings.
Also I want to know how to add a new activity to my project without deleting the MainActivity's "strings" file.
Thank you so much to anyone who can guide me!! I need this app done for me to get a passing grade in my class. Whoever helps gets my apps free for life when i'm a puplisher. Thank you so much!!
Sent from my HUAWEI-M835 using xda app-developers app
Ok.
Add a string this way:
Code:
<string name="[name goes here]">[the string]</string>
(Add this in the strings.xml file in the res/values directory.)
Then in your app you can get it this way:
Code:
String s = getString(R.string.[name goes here]);
Set the text in the xml file that way:
Code:
<Button ...
android:text="@string/[name goes here]"
... />
Add the Activity the normal way. You do not need a second strings.xml file. Just add it to the old one. One for everything.
That helps alot, but,
But whenever I add the @string/ before the text it changes the button name on the visual editor to @string/...."
Also when I added a new activity it replaced my strings file, deleting what I thought was proper strings.
Sent from my HUAWEI-M835 using xda app-developers app
crazy4creationstudios said:
That helps alot, but,
But whenever I add the @string/ before the text it changes the button name on the visual editor to @string/...."
Also when I added a new activity it replaced my strings file, deleting what I thought was proper strings.
Sent from my HUAWEI-M835 using xda app-developers app
Click to expand...
Click to collapse
Which revision of the Android SDK do you have? Updating might help.
Could you please post some pieces of your code which do not work (just the important parts, you can change the names etc.)?
Also im using the SDK and IDE from Google (Eclipse).
And Java JDK
Sent from my HUAWEI-M835 using xda app-developers app
crazy4creationstudios said:
Also im using the SDK and IDE from Google (Eclipse).
And Java JDK
Sent from my HUAWEI-M835 using xda app-developers app
Click to expand...
Click to collapse
Eclipse has not been created by Google. But this does not matter.
Which version of the SDK did you install? (To check this and whether updates are available open the SDK manager. You might need to do this as an administrator.)
I don't know, i'll check in a few minutes at lunch. I downloaded it about 2 weeks ago.
I'll post the codes then too.
Btw none of the code is custom it is from Eclipse when I used the GUI tools
Sent from my HUAWEI-M835 using xda app-developers app
nikwen said:
Eclipse has not been created by Google. But this does not matter.
Which version of the SDK did you install? (To check this and whether updates are available open the SDK manager. You might need to do this as an administrator.)
Click to expand...
Click to collapse
I know but developer.google.com includes it with the ADT bundle.
And I meant to send that b4 u replied haha
Sent from my HUAWEI-M835 using xda app-developers app
Codes
nikwen said:
Which revision of the Android SDK do you have? Updating might help.
Could you please post some pieces of your code which do not work (just the important parts, you can change the names etc.)?
Click to expand...
Click to collapse
Im using API level 17 the Rev. is 2 im using the latest version for x86 systems (32-bit)
My strings file looks like this:
<resources>
<string name="title_activity_socialpage1">Socialpage1</string>
<string name="action_settings">Settings</string>
</resources>
And my Main xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="c4cs.try4.everydayagian"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="8" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="c4cs.try4.everydayagian.MainActivity"
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</activity>
<activity
android:name="c4cs.try4.everydayagian.Socialpage1"
android:label="@string/title_activity_socialpage1"
androidarentActivityName="c4cs.try4.everydayagian.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="c4cs.try4.everydayagian.MainActivity" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
And finally, my Activity_main's XML:
<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"
androidaddingBottom="@dimen/activity_vertical_margin"
androidaddingLeft="@dimen/activity_horizontal_margin"
androidaddingRight="@dimen/activity_horizontal_margin"
androidaddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="32dp"
android:text="Web" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button1"
android:layout_alignParentRight="true"
android:layout_marginRight="46dp"
android:text="Social" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button1"
android:layout_below="@+id/button1"
android:layout_marginTop="41dp"
android:text="To Do" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button3"
android:layout_alignBottom="@+id/button3"
android:layout_alignRight="@+id/button2"
android:text="News" />
<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/button3"
android:layout_below="@+id/button3"
android:layout_marginTop="48dp"
android:text="Weather" />
<Button
android:id="@+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button5"
android:layout_alignRight="@+id/button4"
android:text="Button" />
</RelativeLayout>
crazy4creationstudios said:
Im using API level 17 the Rev. is 2 im using the latest version for x86 systems (32-bit)
My strings file looks like this:
<resources>
<string name="title_activity_socialpage1">Socialpage1</string>
<string name="action_settings">Settings</string>
</resources>
And my Main xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="c4cs.try4.everydayagian"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="8" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="c4cs.try4.everydayagian.MainActivity"
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</activity>
<activity
android:name="c4cs.try4.everydayagian.Socialpage1"
android:label="@string/title_activity_socialpage1"
androidarentActivityName="c4cs.try4.everydayagian.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="c4cs.try4.everydayagian.MainActivity" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
And finally, my Activity_main's XML:
<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"
androidaddingBottom="@dimen/activity_vertical_margin"
androidaddingLeft="@dimen/activity_horizontal_margin"
androidaddingRight="@dimen/activity_horizontal_margin"
androidaddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="32dp"
android:text="Web" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button1"
android:layout_alignParentRight="true"
android:layout_marginRight="46dp"
android:text="Social" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button1"
android:layout_below="@+id/button1"
android:layout_marginTop="41dp"
android:text="To Do" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button3"
android:layout_alignBottom="@+id/button3"
android:layout_alignRight="@+id/button2"
android:text="News" />
<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/button3"
android:layout_below="@+id/button3"
android:layout_marginTop="48dp"
android:text="Weather" />
<Button
android:id="@+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button5"
android:layout_alignRight="@+id/button4"
android:text="Button" />
</RelativeLayout>
Click to expand...
Click to collapse
What is the exact name of your strings file and where is it located?
Where are the problems in the rest of the code?
try right clicking the button or textview from the graphical layout page of your xml. then go to edit text and click on project resources at the top. this should list all the strings that you have. you can choose a string that you have already made or you can click the new string button to create a new string directly from there.
In the "res" folder directory near "layout", where Eclipse puts it automatically.
The other errors were in the manifiest becuase I had ".r" in some wrong places (wich I dont get becuase I never did it in the first place
Sent from my HUAWEI-M835 using xda app-developers app
crazy4creationstudios said:
In the "res" folder directory near "layout", where Eclipse puts it automatically.
The other errors were in the manifiest becuase I had ".r" in some wrong places (wich I dont get becuase I never did it in the first place
Sent from my HUAWEI-M835 using xda app-developers app
Click to expand...
Click to collapse
What does "near layout" mean? Is it in the res/value folder? And is the file called "strings.xml"?
Yes, I just checked
Its in the res/values folder named strings.xml
Sent from my HUAWEI-M835 using xda app-developers app
nikwen said:
What is the exact name of your strings file and where is it located?
Where are the problems in the rest of the code?
Click to expand...
Click to collapse
Did you see that?
nikwen said:
Did you see that?
Click to expand...
Click to collapse
Yeah. The other problems I was having are:
My Manifiest has some incorrect snippets that I didnt add involving action settings(?) Check my strings it was one from it
Sent from my HUAWEI-M835 using xda app-developers app
crazy4creationstudios said:
Yeah. The other problems I was having are:
My Manifiest has some incorrect snippets that I didnt add involving action settings(?) Check my strings it was one from it
Sent from my HUAWEI-M835 using xda app-developers app
Click to expand...
Click to collapse
It was one from it? Which one? We cannot tell what is wrong with your app if we do not get enough information. You know where the error occurs. If you want help, provide us the information we need.
It has got nothing to do with that, but it is still something to correct: In the line
Code:
android:value="c4cs.try4.everydayagian.MainActivit y" />
there is a space between Activit and the y. Remove the space.
Ill find some more specific sections when I have the class tommorrow and PM it to you.
Sent from my HUAWEI-M835 using xda app-developers app
crazy4creationstudios said:
Ill find some more specific sections when I have the class tommorrow and PM it to you.
Sent from my HUAWEI-M835 using xda app-developers app
Click to expand...
Click to collapse
Great.
Set the android:targetSdkVersion to 17 in your manifest
Envoyé depuis mon CINK SLIM avec Tapatalk
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/
Here is the xml
Code:
<LinearLayout 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"
tools:context=".MainActivity"
tools:ignore="MergeRootFrame"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container"
android:layout_weight="1"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="40.0dip"
android:background="#ffffffff"
android:id="@+id/progaction"
android:layout_weight="0.2"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_below="@id/container"
android:layout_alignParentBottom="true">
<TextView
android:gravity="center"
android:text="Level"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
/>
<SeekBar
android:gravity="center"
android:layout_weight="1"
android:id="@+id/seek"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/><TextView
android:gravity="center"
android:text="1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:id="@+id/prog"
/>
</LinearLayout>
</LinearLayout>
Framelayout with id=container contains the fragment used in the activity.
Now the problem is that how to can i get the value of the textView(id=prog) in a particular fragment.i am not able to do it
Error says that "this method cant be used for static context" for the following line
Code:
TextView prog=(TextView) findViewById(R.id.prog);
So please help me to get the value of textView in a fragment
Sent from my GT-S5570 using XDA Premium 4 mobile app
I think your need to call getActivity() first and after this perform activity.findViewById(R.id.prog):
HTML:
Activity a = getActivity();
TextView prog=(TextView) a.findViewById(R.id.prog);
well maybe the easiest way is to hold an instance of the textView in the fragment code, then have a public method to return that instance, so that in the main fragment activity you simply get an instance to the fragment then call the method ?
Have you tried this one? http://stackoverflow.com/questions/6495898/findviewbyid-in-fragment-android
danelab said:
I think your need to call getActivity() first and after this perform activity.findViewById(R.id.prog):
HTML:
Activity a = getActivity();
TextView prog=(TextView) a.findViewById(R.id.prog);
Click to expand...
Click to collapse
Thanks.it worked
nikwen said:
Have you tried this one? http://stackoverflow.com/questions/6495898/findviewbyid-in-fragment-android
Click to expand...
Click to collapse
This is to be used if textView is present in the XML inflated by the fragment itself .but my textView is in XML of mainactivity.
Anyways thanks for the answer.I got the solution
Sent from my GT-S5570 using XDA Premium 4 mobile app
I'm trying to make an app that changes the theme with a ToggleSwitch. My activity in xml is main.xml, and the java is MainActivity.java. The code for the switch is
Code:
<Switch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/switch1"
android:textOff="Light Theme"
android:textOn="Dark Theme" />
.