2

我是android开发的新手。我想知道这个问题的答案:如何控制滑动抽屉的速度或运动?

我已经尝试过了,但它没有奏效。请提供一些例子。

package com.example.list;

import android.app.Activity;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity   {
    ListView l1;
    String[] items = { "Milk", "Butter", "Yogurt", "Toothpaste", "Ice Cream" };
    @Override
        public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        l1 = (ListView)findViewById(R.id.l1);
        final WebView w1 = (WebView)findViewById(R.id.w1);
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                                                                android.R.layout.simple_list_item_1, items);

        l1.setAdapter(adapter);

        l1.setOnItemClickListener(new AdapterView.OnItemClickListener() {

                public void onItemClick(AdapterView<?> parentAdapter, View view, int position,
                                        long id) {
                    switch (position) {
                    case 0:
                        w1.loadData("<html><body><img src=D://download.jpeg width=100 height=100/></body></html>", "text/html", "UTF-8");
                        break;
                    case 1:
                        Toast.makeText(MainActivity.this, "Butter",Toast.LENGTH_SHORT).show();
                        break;
                    case 2:
                        Toast.makeText(MainActivity.this, "Milk",Toast.LENGTH_SHORT).show();
                        break;
                    case 3:
                        Toast.makeText(MainActivity.this, "Butter",Toast.LENGTH_SHORT).show();
                        break;
                    default:
                        break;
                    }
                }
            });
    }
}
4

0 回答 0