相关疑难解决方法(0)

Android应用中的动态ListView

是否有一个工作示例演示如何动态地在ListView中追加其他行?例如:

  1. 您正在从不同的域中提取RSS源
  2. 然后在ListView中显示前10个项目(当你在后台运行其他线程时继续拉动feed)
  3. 滚动并到达列表底部,然后单击按钮以查看更多项目
  4. 然后ListView将附加额外的10个项目,现在共有20个项目.

任何建议如何实现这一目标?

尼古拉斯

java android listview dynamic

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

listView动态添加项目

我曾经ListView动态添加项目,但有一个问题是没有平滑添加.我的listActivity中有textView和按钮,Iwant to Press按钮,然后TextView的文字可以自动添加ListView,但我按下按钮,它不工作,除非我输入内容后,按"确定"键,然后按下按钮,TextView's文字即可自动添加到ListView.我不知道为什么.如果我连续按下按钮,为3次,则按"确定"键,内容

自动添加列表

查看3次.

 public class DynamicListItems extends ListActivity {
   private static final String   ITEM_KEY   = "key";
   ArrayList<HashMap<String, String>>   list= new ArrayList<HashMap<String, String>>();
private SimpleAdapter   adapter;
private EditText    newValue;@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.dynamic_list);
    newValue = (EditText) findViewById(R.id.new_value_field);

    setListAdapter(new SimpleAdapter(this, list, R.layout.row, new String[] { ITEM_KEY }, new int[] { R.id.list_value }));
    ((ImageButton) findViewById(R.id.button)).setOnClickListener(getBtnClickListener());
}

private OnClickListener getBtnClickListener() {
    return new OnClickListener() {
        public void onClick(View view) …
Run Code Online (Sandbox Code Playgroud)

android listview

15
推荐指数
1
解决办法
6万
查看次数

ListView的Layout_width

好的,我遇到了listView的attribut layout_width的问题.

在我的项目中,我的listview的背景图像不符合屏幕的宽度.所以我在wrap_content上设置了layout_width,并且我将listView水平居中.

看起来这是一个坏主意,因为在适配器中,GetView方法被调用的次数是显示的单元格数的3倍以上.如果我在fill_parent上设置layout_width,问题就解决了.我创建了一个显示问题的简单项目.

这是活动的xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ListView
    android:id="@android:id/list"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

item_list xml:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="10dp"
    android:textSize="16sp" >
</TextView>
Run Code Online (Sandbox Code Playgroud)

最后活动:

package fr.example.android.listviewbug;

import android.app.ListActivity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;

public class ExampleListViewBugActivity extends ListActivity{
    public static int cpt;

    public static final String[] COUNTRIES = new String[] {
        "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra",
        "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", …
Run Code Online (Sandbox Code Playgroud)

android listview

5
推荐指数
2
解决办法
9402
查看次数

Android Softkeyboard将数值输入edittext非常慢

我有TableLayout,其中包含多个产品.每行包含代码,描述数量,价格,折扣价值,.....取决于用户输入数量,折扣价值,折扣数量和其他一些值也会计算.

当用户点击editText软键盘时,这个也可以,工作正常

我的问题是当用户按下数字键非常慢以在EditText中显示.

例如我从键盘按3,经过7或8秒后只显示在特定的editText中.如何缩短此时间线...

这是我的产品图片:

ProductImage

请有人建议为什么会这样?

像这样的代码:

     for (int i = initil; i <end; i++) {
        .............
        ............
        final EditText txtQty = new EditText(this);
            txtQty.setHeight(1);
            txtQty.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, 42));
            txtQty.setInputType(InputType.TYPE_CLASS_PHONE);
            txtQty.setImeOptions(EditorInfo.IME_ACTION_DONE);
            txtQty.setImeOptions(EditorInfo.IME_ACTION_NEXT);
            txtQty.setSelectAllOnFocus(true);
            txtQty.setTextSize(9);
            txtQty.setHint("0.0");
    //      txtQty.setOnEditorActionListener(new DoneOnEditorActionListener());
//          txtQty.setHighlightColor(R.color.green);
            tr.addView(txtQty); 

            InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            mgr.showSoftInput(txtQty, InputMethodManager.SHOW_IMPLICIT);

            mgr.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT,InputMethodManager.HIDE_IMPLICIT_ONLY);
            ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(txtQty.getWindowToken(), 0);

            txtQty.setOnEditorActionListener( new OnEditorActionListener() {
                public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                    Log.i("KeyBoard" ,"Inside the Edit Text");
                    .............................
        } });
Run Code Online (Sandbox Code Playgroud)

android soft-keyboard

5
推荐指数
1
解决办法
2284
查看次数

标签 统计

android ×4

listview ×3

dynamic ×1

java ×1

soft-keyboard ×1