Dynamically set screen orientation android
Set following code before setting activity layout as follow
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(r.layout.yourlayout);
You have changed ViewPager's page by sliding it. You can also change page by click on next and previous button.
int globalPosition = 0;
// checking if pager can scroll or not
boolean can = mPager.canScrollHorizontally(1);
if(can)
{
mPager.setCurrentItem(++globalPosition,true);
}
boolean can = mPager.canScrollHorizontally(-1);
if(can)
{
mPager.setCurrentItem(--globalPosition,true);
}
mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
globalPosition = position;
}
});
ViewPager is nothing but horizontal scroller for entire screens.
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/your_pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
mPager = (ViewPager) findViewById(R.id.your_pager);
ViewPager mPager;
PagerAdapter mPagerAdapter;
public static String [] pageItem = new String[]{"Page 1","Page 2","Page 3"};
mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager()); mPager.setAdapter(mPagerAdapter);
private class ScreenSlidePagerAdapter extends
FragmentStatePagerAdapter
{
public ScreenSlidePagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
//
return new MyFragment(position);
}
@Override
public int getCount() {
return pageItem.length;
}
}public class MyFragment extends Fragment {
TextView textView;
int position = 0;
public MyFragment(int position)
{
this.position = position;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
ViewGroup rootView = (ViewGroup) inflater.inflate(
R.layout.my_screen_fragment, container, false);
textView = (TextView)rootView.findViewById(R.id.my_page_tv);
textView.setText(activityClassObject.pageItem[position]);
return rootView;
}
}
How to create custom checkbox. Applying stylish checkbox Android
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<!--checked image-->
<item android:drawable="@drawable/checkbox_checked"
android:state_checked="true"/>
<!--unchecked image-->
<item android:drawable="@drawable/checkbox"
android:state_checked="false"/>
</selector>android:button="@drawable/checkbox_button"
<FrameLayout
android:id="@+id/your_frame_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true" />Fragment myFragment = new MyFirstFragment();
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fTransaction = fragmentManager
.beginTransaction()
.replace(R.id.your_frame_layout, bodyFragment)
.addToBackStack("myprofile");
fTransaction.commit();
Android activity is simple and best way to provide interface to user. Fragment are very similar to activity. But it will be much better if we call it small piece of activity. So an activity can have multiple fragments
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub return super.onCreateView(inflater, container, savedInstanceState); }
@Override public void onAttach(Activity activity) { // TODO Auto-generated method stub super.onAttach(activity); }
@Override
public View onCreateView(LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
View localView = inflater.inflate(R.layout.your_xml.xml,
container, false);
return localView; //super.onCreateView(inflater, container, savedInstanceState);
}
YourActivity yourActivityObject;
@Override
public void onAttach(Activity activity) {
yourActivityObject = (YourActivity)activity;
super.onAttach(activity);
}
Fragment yourSecondFragment = new YourSecondFragment();
FragmentManager fm = yourActivityObject.getSupportFragmentManager();
//yourSecondFragment.setArguments(Bundle) // to pass argument to next fragment.
fm.beginTransaction().replace(R.id.parent_activity_frame_layout,
yourSecondFragment).addToBackStack("myfragmentstring").commit();
// addToBackStack method before commit is used to implement back button functionality later.
In parent activity add onBackPressed() method and paste the following code
int f = getSupportFragmentManager().getBackStackEntryCount();
Log.v(tag, "onBackPressed ["+f+"]");
if (f <= 1)
this.finish();
else {
getSupportFragmentManager().popBackStackImmediate();
}
First of all be clear about signed and unsigned apk. Signed apks keeps its digital signature certificate with it, while unsigned does not. The Android system requires that all installed applications be digitally signed with a certificate whose private key is held by the application's developer. The Android system uses the certificate as a means of identifying the author of an application and establishing trust relationships between applications.
As I guess unsigned apk is for facilitate another user to sign apk with its own key.
Remember the following points.