标签: swipe

Android:如何处理从右到左的滑动手势

我希望我的应用能够识别用户在手机屏幕上从右向左滑动的时间.

这该怎么做?

android gesture-recognition swipe

424
推荐指数
12
解决办法
38万
查看次数

在iPhone和Android上通过JavaScript检测手指滑动

如何检测用户使用JavaScript在网页上向某个方向滑动手指?

我想知道是否有一个解决方案适用于iPhone和Android手机上的网站.

javascript iphone android swipe

247
推荐指数
14
解决办法
23万
查看次数

动态添加和删除视图到viewpager

(我想出了一个解决方案 - 请在下面的答案部分看到我的帖子.)

在我的应用程序中,用户将从他的数据的单个视图开始.我想添加一个ViewPager,并允许用户根据需要添加更多视图.我该怎么做呢?(我不想使用FragmentPagerAdapter.)

我已经阅读了无数的帖子和概述,但我仍然遗漏了一些东西.这是我认为我理解的:

MainActivity创建一个ViewPager和PagerAdapter:

ViewPager pager = null;
MainPagerAdapter adapter = null;
public void onCreate (Bundle savedInstanceState)
{
  super.onCreate (savedInstanceState);
  pager = new ViewPager (this);
  setContentView (pager);

  adapter = new MainPagerAdapter();
  pager.setAdapter (adapter); 

  View v0 = code_to_create_initial_view();
  adapter.add (v0, 0);      
}
Run Code Online (Sandbox Code Playgroud)

使用PagerAdapter提供视图集.为此,我似乎需要添加和删除视图的方法,就像这样; 显然需要更多的东西来告诉ViewPager的内容已经改变以及如何显示更改:

class MainPagerAdapter extends PagerAdapter
{
  // This holds all the currently displayable views, in order from left to right.
  private ArrayList<View> views = new ArrayList<View>();

  public void addView (View v, int position)
  {
    views.add (position, …
Run Code Online (Sandbox Code Playgroud)

android swipe android-viewpager

160
推荐指数
2
解决办法
17万
查看次数

设置UISwipeGestureRecognizer的方向

我想在基于视图的iPhone项目中添加简单的滑动手势识别功能.应识别所有方向(右,下,左,上)的手势.

它在UISwipeGestureRecognizer的文档中说明:

您可以通过使用按位或操作数指定多个UISwipeGestureRecognizerDirection常量来指定多个方向.默认方向是UISwipeGestureRecognizerDirectionRight.

但对我来说它不起作用.当所有四个方向都被"或"时,仅识别左右滑动.

- (void)viewDidLoad {
    UISwipeGestureRecognizer *recognizer;

    recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
    [recognizer setDirection:(UISwipeGestureRecognizerDirectionRight | UISwipeGestureRecognizerDirectionDown | UISwipeGestureRecognizerDirectionLeft | UISwipeGestureRecognizerDirectionUp)];
    [[self view] addGestureRecognizer:recognizer];
    [recognizer release]; 
    [super viewDidLoad];
}

-(void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer {
    NSLog(@"Swipe received.");
}
Run Code Online (Sandbox Code Playgroud)

我通过在视图中添加四个识别器来修复此问题,但我很想知道它为什么不像在文档中宣传的那样工作?

- (void)viewDidLoad {
    UISwipeGestureRecognizer *recognizer;

    recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
    [recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
    [[self view] addGestureRecognizer:recognizer];
    [recognizer release];

    recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
    [recognizer setDirection:(UISwipeGestureRecognizerDirectionUp)];
    [[self view] addGestureRecognizer:recognizer];
    [recognizer release];

    recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
    [recognizer setDirection:(UISwipeGestureRecognizerDirectionDown)];
    [[self view] addGestureRecognizer:recognizer]; …
Run Code Online (Sandbox Code Playgroud)

iphone swipe ios uiswipegesturerecognizer

131
推荐指数
6
解决办法
9万
查看次数

如何识别所有4个方向的滑动

我需要使用滑动来识别向下然后向右滑动手势.但是在快速的UISwipeGestureRecognizer上预先确定了正确的方向..而且我不知道如何使用其他方向.

direction swipe ios uiswipegesturerecognizer swift

123
推荐指数
7
解决办法
10万
查看次数

抓住轻扫以解雇事件

我正在使用android通知在服务完成(成功或失败)后提醒用户,并且我想在完成该过程后删除本地文件.

我的问题是,如果发生故障 - 我想让用户进行"重试"选项.如果他选择不重试并解除通知我想删除为处理目的而保存的本地文件(图像......).

有没有办法捕获通知的刷卡到解雇事件?

service notifications android temporary-files swipe

80
推荐指数
2
解决办法
4万
查看次数

在向左滑动的同时在UITableViewCell中自定义编辑视图.Objective-C或Swift

如何使用Objective C在iOS7 UITableView中制作自定义编辑视图,如Evernote或Apple Reminders应用程序,同时向左滑动.我试图设置自定义editingAccessoryView,但这不起作用.

Evernote编辑视图:

在此输入图像描述 提醒编辑视图:

在此输入图像描述

我目前的代码是

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    return YES;
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        NSLog(@"delete");
    }
}
Run Code Online (Sandbox Code Playgroud)

我试图用以下方法解决问题:(UITableViewController.h)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    //make cell

    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
    [view setBackgroundColor:[UIColor greenColor]];
    //add Buttons to view

    cell.editingAccessoryView = view;

    return cell;
}
Run Code Online (Sandbox Code Playgroud)

与之相同:(UITableViewCell)

- (void)willTransitionToState:(UITableViewCellStateMask)state;
- (void)setEditing:(BOOL)editing animated:(BOOL)animated;
- (UIView*)editingAccessoryView;
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview swipe ios swift

73
推荐指数
6
解决办法
11万
查看次数

PagerAdapter开始位置

我使用以下示例来表达我的viewPager:http: //code.google.com/p/viewpagerexample/issues/list

这个例子的问题是我无法弄清楚如何设置我的起始位置,默认的起始位置是0.基本上我不能控制左边或右边是否有可用的视图.

有没有办法控制中心的View当前位置?有更好的方法吗?是否有可能使其圆形?

android swipe android-viewpager

68
推荐指数
7
解决办法
7万
查看次数

在Android中设置ViewPager的默认页面

我使用以下代码,MAX是2页.默认情况下,位置为0并在右侧添加新页面.我膨胀了两个布局文件.

如何在应用启动时显示page1并在左侧添加新页面?谢谢.

main.xml中

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">


    <android.support.v4.view.ViewPager
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:id="@+id/pagerView" />


</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

Java代码

public class MyPagerActivity extends Activity {
    private Context context;    
    private int pageNumber;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        context = this;

        ViewPager pagerView = (ViewPager)findViewById(R.id.pagerView);
        pagerView.setAdapter(new AwesomePagerAdapter());    

    }


    private class AwesomePagerAdapter extends PagerAdapter{

        @Override
        public void destroyItem(View collection, int position, Object view) {
            ((ViewPager) collection).removeView((View)view);            
        }

        @Override
        public void finishUpdate(View arg0) {
            //setPageTitles(getPageNumber());
        }

        @Override
        public int getCount() {
            return …
Run Code Online (Sandbox Code Playgroud)

animation android swipe android-viewpager

65
推荐指数
3
解决办法
5万
查看次数

Android刷卡列表

有没有人有一个简单的ListActivity示例在列中显示Textviews,当您从左向右滑动时,您会在新视图中看到该行?这可以说是编辑该行的数据或显示该行的更多详细信息.请不要参考代码shogun或其他网站,因为我用谷歌搜索,并没有看到这个答案.

android list textview listactivity swipe

47
推荐指数
1
解决办法
3万
查看次数