I need to create a "Sliding activity" , which will slide when the user swipes it. When the user "swipes" it to the left, the activity should slide to the left, and the new activity will come to the screen from the right side. You can't hold it in middle. The same thing is in Yahoo Mail app. You can see this when you are reading a mail, and swipe the mail to the left to move to the next mail. It is like below.
In the image, you can see the next mail (With the title 'Thank you') is opening from the side. In my case, they are 2 different activities. It is also preferred that we can show a small part of the next activity at the right side of the current activity (like in windows phones) so the user know he has to swipe. That part is now mandatory anyway.
I tried to do it with this answer but it is not what I am seeking for. Any idea please?
NOTE
If I go for Fragments, lot of classes will be changed or be re coded entirely.
UPDATE
Please have a look at the following code. In here, when I swipe on SalesInquiry.java
The NewLead.java
should be open, with the above explained effects.
DropDownMenu.java
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
public class DropDownMenu extends Activity {
private TextView addInquiry, addEvent, additionalInfo, addToContacts;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_drop_down_menu);
//Intializing instance variables
addInquiry = (TextView)findViewById(R.id.menu_add_inquiry);
addEvent = (TextView)findViewById(R.id.menu_add_event);
additionalInfo = (TextView)findViewById(R.id.menu_additional_info);
addToContacts = (TextView)findViewById(R.id.menu_add_to_contacts);
//Register the Listeners
addInquiry.setOnClickListener(new AddInquiryEvent());
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.drop_down_menu, menu);
return true;
}
//Test Button
private class AddInquiryEvent implements OnClickListener
{
@Override
public void onClick(View arg0)
{
// TODO Auto-generated method stub
Intent intent = new Intent(DropDownMenu.this,NewLead.class);
startActivity(intent);
}
}
public void onMenuItemClicked(View view) {
switch (view.getId()) {
case R.id.menu_add_inquiry:
Intent intent = new Intent(DropDownMenu.this,NewLead.class);
startActivity(intent);
break;
default:;
}
}
}
SalesInquery.java
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.Window;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
public class SalesInqury extends DropDownMenu {
private ImageView addNewSalesInqury;
private RelativeLayout salesInquryMainLayout;
private TextView testEditSales;
@Override
protected void onCreate(Bundle savedInstanceState) {
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sales_inqury);
//Intializing instance variables
addNewSalesInqury = (ImageView)findViewById(R.id.add_new_sales_inqury_btn);
salesInquryMainLayout = (RelativeLayout)findViewById(R.id.sales_inqury_main_layout);
testEditSales = (TextView)findViewById(R.id.testWord);
//Registering Event handlers
addNewSalesInqury.setOnClickListener(new addNewSalesInquryEvent());
salesInquryMainLayout.setOnTouchListener(mainLayoutSwiped);
testEditSales.setOnClickListener(new OpenSalesDemo()); //TESTING DEMO!!!!!
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.sales_inqury, menu);
return true;
}
//Event Handler for Add New Sales Inquery Button
private class addNewSalesInquryEvent implements OnClickListener
{
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
Intent intent = new Intent(SalesInqury.this,NewLead.class);
startActivity(intent);
}
}
//SWIP LISTENER
private OnTouchListener mainLayoutSwiped = new OnSwipeTouchListener()
{
public boolean onSwipeLeft()
{
Intent intent = new Intent(SalesInqury.this,NewLead.class);
startActivity(intent);
return true;
}
};
//
//
// TESTING FUNCTION!!
//
//
//Testing function for sales lead opening
private class OpenSalesDemo implements OnClickListener
{
@Override
public void onClick(View arg0)
{
// TODO Auto-generated method stub
Intent intent = new Intent(SalesInqury.this,EditLeads.class);
startActivity(intent);
}
}
}