这是我第一次使用android.我正在尝试将项目添加到ListView.我使用Tabs,并且看到添加项目的唯一方法是更改选项卡,然后返回第一个选项卡.
我四处寻找,而且我总能找到
adapter.notifyDataSetChanged();
Run Code Online (Sandbox Code Playgroud)
但对我不起作用.
正如我所说,我创建了项目,固定标签+滑动.我只想让listviews具有EditText,Spinner和Button.在用于选项卡的片段底部,我有一个ImageButton.我想点击它并有一个新的行.
我的定制适配器:
package com.andreapivetta.uconverter;
import java.util.ArrayList;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
public class CustomAdapter extends ArrayAdapter<String> {
private final Context context;
private final int resourceID;
public CustomAdapter(Context context, int resource, ArrayList<String> bah) {
super(context, resource, bah);
this.context = context;
this.resourceID = resource;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(resourceID, parent, false);
return rowView;
}
}
Run Code Online (Sandbox Code Playgroud)
fragment_main_dummy.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" …Run Code Online (Sandbox Code Playgroud)