拖放与CWAC-touchlist [英] Drag and Drop with cwac-touchlist

查看:233
本文介绍了拖放与CWAC-touchlist的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个问题。

1 如何使应用程序记住的ListView新秩序是什么我做拖动和删除。就像现在,我可以重新排列物品但每次我打开应用程序的时候,我不得不再次重新排列物品。

2 我的应用程序应当从每一个项目打开不同的网页。但是,当我重​​新排列物品,然后Web链接不重新排序。他们坚持的一样。

例如像:我有项目谷歌和雅虎等等环节都http://google.com和http://yahoo.com。然后我重新排列项目:谷歌是顶部,但我拖累雅虎顶部。之后,当我preSS雅虎项目打开它谷歌的网站,当我preSS谷歌它打开雅虎的网站。

下面是我如何使OnItemClickListener:

  getListView()。setOnItemClickListener(新OnItemClickListener(){
    公共无效onItemClick(适配器视图<>母公司,观景,
            INT位置,长的id){
        字符串内容=链接[位置]
        意图showContent =新意图(getApplicationContext()
                Web.class);
        showContent.setData(Uri.parse(内容));
        startActivity(showContent);
    }});


解决方案

  

如何使应用程序记住的ListView新秩序是我用拖放的。就像现在,我可以重新排列物品但每次我打开应用程序的时候,我不得不再次重新排列物品。


加载它放回存储时的顺序地方(例如,在数据库中的表顺序列)和重新排序的数据你的适配器


  

我的应用应该每个项目打开不同的网页。但是,当我重​​新排列物品,然后Web链接不重新排序。他们坚持的一样。


文档:


  

在code,你设置了 TouchListView 就像一个普通的的ListView ,但你需要通过 setDropListener注册一个 TouchListView.DropListener ()。在你的听众,你需要做些什么来影响通过拖和拖放操作要求重新排序。在示范项目,这是除去旧位置的条目,并把它在新的位置的问题。


I have two questions.

1. How to make app remember new order in ListView what I made with drag and drop. Like now I can reorder items but every time I open app, I have to reorder items again.

2. My app should open different webpage from each item. But when I reorder items then web links doesn't reorder. They stick on same.

Like example: I have items Google and Yahoo! so links are "http://google.com" and "http://yahoo.com". Then I reorder item: Google was top but I drag Yahoo to top. After that when I press "Yahoo!" item it open Google's website and when I press "Google" it opens Yahoo's website.

Here is how I have made OnItemClickListener:

getListView().setOnItemClickListener(new OnItemClickListener() {


    public void onItemClick(AdapterView<?> parent, View view,
            int position, long id) {
        String content = links[position];
        Intent showContent = new Intent(getApplicationContext(),
                Web.class);
        showContent.setData(Uri.parse(content));
        startActivity(showContent);
    }

});

解决方案

How to make app remember new order in ListView what I made with drag and drop. Like now I can reorder items but every time I open app, I have to reorder items again.

Store the order somewhere (e.g., sequence column in your database table) and re-order the data when loading it back into your Adapter.

My app should open different webpage from each item. But when I reorder items then web links doesn't reorder. They stick on same.

Quoting the documentation:

In code, you set up a TouchListView just like a regular ListView, except that you need to register a TouchListView.DropListener via setDropListener(). In your listener, you will need to do something to affect the re-ordering requested via the drag-and-drop operation. In the demo project, this is a matter of removing the entry from the old position and putting it in the new position.

这篇关于拖放与CWAC-touchlist的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆