Monday 13 May 2013
Tuesday 7 May 2013
View Flipper in android example
Simple
ViewAnimator
that
will animate between two or more views that have been added to it.
Only one child is shown at a time. If requested, can automatically
flip between each child at a regular interval.
The
ViewFlipper is a nifty widget that can be used to slide views in and
out of the user’s current view port. At times I find it a handy UI
replacement for the tab widget (which
I’ve stated before I’m not overly fond of).
What I like most about the ViewFlipper is the slick user experience.
It’s the same sort of effect that is prevalent on Windows
Phone 7,
and was used by Google to jazz up the latest incarnation of the
Android
Market.
Despite
the widget only recently gaining popularity on Android, it’s been
around since version 1.0 of the API. (Read
the official ViewFlipper documentation.)
However, I don’t think the developer documentation makes it
immediately obvious how to use the widget in your applications. In
particular, puzzling through the sliding in and out animation
transitions can be a little tough. Maybe not as tough as ignoring the
candy bowl sitting on my kitchen counter, assuring me no one will
notice if I take just one more Laffy Taffy, but still, it requires
you to put on your thinking cap. If you’d like to download and
import the entire project detailed in this tutorial, you can do so
here.
activity_main.xml
<?xml
version="1.0"
encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
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:gravity="center"
android:text="View
Flipper Demo" />
<ViewFlipper
android:id="@+id/view_flipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="6dip"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A
dog limps into a saloon and says..."
android:textColor="#00ff00"
android:textSize="14sp"
android:textStyle="bold"
>
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I'm
looking for the man who shot my paw!"
android:textColor="#00ff00"
android:textSize="14sp"
android:textStyle="bold"
>
</TextView>
</LinearLayout>
</ViewFlipper>
</LinearLayout>
MainActivity.java
package
com.example.viewflipper;
import
android.app.Activity;
import
android.os.Bundle;
import
android.view.Menu;
import
android.view.MotionEvent;
import
android.widget.ViewFlipper;
public
class
MainActivity extends
Activity {
private
ViewFlipper
vf;
private
float
lastX;
/**
Called when the activity is first created. */
@Override
public
void
onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
vf
= (ViewFlipper)
findViewById(R.id.view_flipper);
}
@Override
public
boolean
onCreateOptionsMenu(Menu
menu) {
//
Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main,
menu);
return
true;
}
public
boolean
onTouchEvent(MotionEvent
touchevent) {
switch
(touchevent.getAction()) {
case
MotionEvent.ACTION_DOWN:
{
lastX
= touchevent.getX();
break;
}
case
MotionEvent.ACTION_UP:
{
float
currentX = touchevent.getX();
if
(lastX <
currentX) {
if
(vf.getDisplayedChild()
== 0)
break;
vf.setInAnimation(this,
R.anim.in_from_left);
vf.setOutAnimation(this,
R.anim.out_to_right);
vf.showNext();
}
if
(lastX >
currentX) {
if
(vf.getDisplayedChild()
== 1)
break;
vf.setInAnimation(this,
R.anim.in_from_right);
vf.setOutAnimation(this,
R.anim.out_to_left);
vf.showPrevious();
}
break;
}
}
return
false;
}
}
and
Two another animation file;
to create that file first you need to create a new folder into /res named animation and into that you need to create xml files.
in_from_left.xml
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
>
<!--
<translate
android:duration="1400"
android:fromXDelta="-100%"
android:fromYDelta="0%"
android:toXDelta="0%"
android:toYDelta="0%"
/> -->
<!--
<scale android:duration="100"
android:fromXScale="100%"
android:fromYScale="0%"
android:repeatMode="reverse"/>
-->
<rotate
android:fromDegrees="5"
android:toDegrees="50"
android:duration="5000"/>
</set>
in_from_right.xml
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
>
<translate
android:duration="1400"
android:fromXDelta="100%"
android:fromYDelta="0%"
android:toXDelta="0%"
android:toYDelta="0%"
/>
</set>
Screen
shot
Thanks
SlidingDrawer in Android Example
Sliding Drawer :
SlidingDrawer
drawer;
This
class was deprecated in API level 17.
This class is not supported anymore. It is recommended you base your own implementation on the source code for the Android Open Source Project if you must use it in your application.
This class is not supported anymore. It is recommended you base your own implementation on the source code for the Android Open Source Project if you must use it in your application.
SlidingDrawer
hides content out of the screen and allows the user to drag a handle
to bring the content on screen. SlidingDrawer can be used vertically
or horizontally. A special widget composed of two children views: the
handle, that the users drags, and the content, attached to the handle
and dragged with it. SlidingDrawer should be used as an overlay
inside layouts. This means SlidingDrawer should only be used inside
of a FrameLayout or a RelativeLayout for instance. The size of the
SlidingDrawer defines how much space the content will occupy once
slid out so SlidingDrawer should usually use match_parent for both
its dimensions. Inside an XML layout, SlidingDrawer must define the
id of the handle and of the content:
activity_main.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"
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"
>
<SlidingDrawer
android:id="@+id/slidingDrawer1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:content="@+id/content"
android:allowSingleTap="true"
android:handle="@+id/handle"
>
<Button
android:id="@+id/handle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/up"
/>
<LinearLayout
android:id="@+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="vertical"
>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
/>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2"
/>
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3"
/>
</LinearLayout>
</SlidingDrawer>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/slidingDrawer1"
android:layout_alignTop="@+id/slidingDrawer1"
android:layout_marginLeft="73dp"
android:gravity="center"
android:text="Sliding
drawer example" />
</RelativeLayout>
MainActivity.java
package
com.example.slidingdrawer;
import
android.app.Activity;
import
android.os.Bundle;
import
android.view.Menu;
import
android.widget.Button;
import
android.widget.SlidingDrawer;
import
android.widget.SlidingDrawer.OnDrawerCloseListener;
import
android.widget.SlidingDrawer.OnDrawerOpenListener;
public
class
MainActivity extends
Activity {
Button
button;
@SuppressWarnings("deprecation")
@Override
protected
void
onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
drawer=(SlidingDrawer)findViewById(R.id.slidingDrawer1);
button=(Button)findViewById(R.id.handle);
drawer.setOnDrawerOpenListener(new
OnDrawerOpenListener() {
@Override
public
void
onDrawerOpened() {
//
TODO
Auto-generated method stub
button.setBackgroundResource(R.drawable.down);
}
});
drawer.setOnDrawerCloseListener(new
OnDrawerCloseListener() {
@Override
public
void
onDrawerClosed() {
//
TODO
Auto-generated method stub
button.setBackgroundResource(R.drawable.up);
}
});
}
@Override
public
boolean
onCreateOptionsMenu(Menu menu) {
//
Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main,
menu);
return
true;
}
}
Screen
Shot:
Android game free open source code download
Android
2d/3d game development :
Android
Open source game free download from here:
Our Android Applications on Google Play
Thanks
NovaRadix Technology, India
Skype : novaradix
Gmail: novaradix@gmail.com
Android PDF Reader Open Source code application free Download
Pdf Reader android
source code on github.
Pdf Reader android open
source project free downloaded from here :
Our Android Applications on Google Play
Thanks
NovaRadix Technology, India
Skype : novaradix
Gmail: novaradix@gmail.com
Android Configchanges Attributes - Manifest Description
To declare that your
activity handles a configuration change, edit the appropriate
<activity>
element in your
manifest file to include the android:configChanges
attribute with a value that represents the configuration you want to
handle. Possible values are listed in the documentation for the
android:configChanges
attribute (the
most commonly used values are "orientation"
to prevent restarts when the screen orientation changes and
"keyboardHidden"
to prevent
restarts when the keyboard availability changes). You can declare
multiple configuration values in the attribute by separating them
with a pipe |
character.
android:configChanges=["mcc", "mnc", "locale",
"touchscreen",
"keyboard", "keyboardHidden",
"navigation",
"screenLayout", "fontScale", "uiMode",
"orientation",
"screenSize", "smallestScreenSize"]
Now, when one of these
configurations change,
MyActivity
does
not restart. Instead, the MyActivity
receives a call to onConfigurationChanged()
.
This method is passed a Configuration
object that specifies the new device configuration. By reading fields
in the Configuration
, you can determine
the new configuration and make appropriate changes by updating the
resources used in your interface. At the time this method is called,
your activity's Resources
object is
updated to return resources based on the new configuration, so you
can easily reset elements of your UI without the system restarting
your activity.
Lists configuration
changes that the activity will handle itself. When a configuration
change occurs at runtime, the activity is shut down and restarted by
default, but declaring a configuration with this attribute will
prevent the activity from being restarted. Instead, the activity
remains running and its
onConfigurationChanged()
method is called.
Value
|
Description
|
"
mcc " |
The IMSI mobile country code (MCC) has changed
— a SIM has been detected and updated the MCC.
|
"
mnc " |
The IMSI mobile network code (MNC) has changed
— a SIM has been detected and updated the MNC.
|
"
locale " |
The locale has changed — the user has
selected a new language that text should be displayed in.
|
"
touchscreen " |
The touchscreen has changed. (This should never
normally happen.)
|
"
keyboard " |
The keyboard type has changed — for example,
the user has plugged in an external keyboard.
|
"
keyboardHidden " |
The keyboard accessibility has changed — for
example, the user has revealed the hardware keyboard.
|
"
navigation " |
The navigation type (trackball/dpad) has
changed. (This should never normally happen.)
|
"
screenLayout " |
The screen layout has changed — this might be
caused by a different display being activated.
|
"
fontScale " |
The font scaling factor has changed — the
user has selected a new global font size.
|
"
uiMode " |
The user interface mode has changed — this
can be caused when the user places the device into a desk/car dock
or when the night mode changes. See
UiModeManager .
Added in API level 8. |
"
orientation " |
The screen
orientation has changed — the user has rotated the device.
Note: If your application
targets API level 13 or higher (as declared by the
minSdkVersion
and targetSdkVersion attributes),
then you should also declare the "screenSize"
configuration, because it also changes when a device switches
between portrait and landscape orientations. |
"
screenSize " |
The current
available screen size has changed. This represents a change in the
currently available size, relative to the current aspect ratio, so
will change when the user switches between landscape and portrait.
However, if your application targets API level 12 or lower, then
your activity always handles this configuration change itself
(this configuration change does not restart your activity, even
when running on an Android 3.2 or higher device).
Added in API level 13.
|
"
smallestScreenSize " |
The physical screen
size has changed. This represents a change in size regardless of
orientation, so will only change when the actual physical screen
size has changed such as switching to an external display. A
change to this configuration corresponds to a change in the
smallestWidth configuration. However, if your application targets
API level 12 or lower, then your activity always handles this
configuration change itself (this configuration change does not
restart your activity, even when running on an Android 3.2 or
higher device).
Added in API level 13.
|
"
layoutDirection " |
The layout direction has changed. For example,
changing from left-to-right (LTR) to right-to-left (RTL). Added
in API level 17.
|
For More Details :
Our Android
Applications on Google Play
Thanks
NovaRadix Technology,
India
Skype : novaradix
Gmail:
novaradix@gmail.com
Wednesday 24 April 2013
Make SplashScreen in android
Make Splash screen in android
wait for some time in android for display any screen like splash screen.
Timer timer2 = new Timer();
timer2.schedule(new TimerTask() {
@Override
public void run() {
Intent intent = new Intent(Spash_Activity.this,
LoginActivity.class);
startActivity(intent);
finish();
}
}, 3000);
here is the "3000" means 3 second wait for load another screen
Subscribe to:
Posts (Atom)
Call web services easily
get source code from here, Download
-
Pdf Reader android source code on github. https://github.com/chintanvyas89/android-pdf-viewer https://github.com/jblough/And...
-
To declare that your activity handles a configuration change, edit the appropriate <activity> element in your manifest ...
-
get source code from here, Download