Android ListView背景色遮罩onClick波纹效果

时间:2019-12-16 16:15:59

标签: java android android-listview background-color

我有一个自定义SELECT FIRST 1 acbccccic FROM acbcc WhERE (acbccscic=4 OR acbccscic=5) AND acbccccic IN (SELECT acbcaccic FROM acbca WHERE acbcacage=116437) ORDER BY acbccccic DESC ,其中每个元素都有一个图标和3个SELECT SUM(actdtmahi+actdtmahd+actdtmahv) AS saldo FROM actdt WHERE actdtcage=116437 AND actdtmrcb=0 AND actdtccic IN (SELECT FIRST 1 acbccccic FROM acbcc WHERE (acbccscic=4 OR acbccscic=5) AND acbccccic IN (SELECT acbcaccic FROM acbca WHERE acbcacage=116437) ORDER BY acbccccic DESC) 。我可以将背景更改为白色,但是现在单击文本时看不到动态效果。我的意思是触摸时呈灰色(波纹效果)。

这是ListView

TextView

我的MainActivity中的方法 ListView mListView = findViewById(R.id.list_layout); names = new ArrayList<>(); macs = new ArrayList<>(); adapter= new CompleteListAdapter(this, names, macs); mListView.setAdapter(adapter); adapter.notifyDataSetChanged();

CompleteListAdapter

这是extends BaseAdapter

的一部分
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View rowView = LayoutInflater.from(mContext).inflate(R.layout.two_line_icon, parent, false);
    TextView text1 = (TextView) rowView.findViewById(R.id.text1);
    TextView text2 = (TextView) rowView.findViewById(R.id.text2);
    ImageView icon = (ImageView) rowView.findViewById(R.id.icon);

    text1.setText(names.get(position));
    text2.setText(macs.get(position));

    return rowView;
}

这是main_activity.xml的单个条目:<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:gravity="center_horizontal" android:descendantFocusability="beforeDescendants" android:focusableInTouchMode="true" tools:context="com.example.myapp.MainActivity"> <ListView android:id="@+id/list_layout" android:layout_width="match_parent" android:layout_height="400dp"></ListView> </LinearLayout>

ListView

0 个答案:

没有答案