listview.setOnItemClickListener ( new AdapterView.OnItemClickListener () {
    @Override
    public void onItemClick(AdapterView <?> view3, View view, int view1, long view2) {


        final TextView countid = (TextView) view.findViewById ( R.id.id );
        final TextView count_counting = (TextView) view.findViewById ( R.id.text_view_countiing );
        final TextView any_name = (TextView) view.findViewById ( R.id.textviewname );
        final ImageView deletebutton = (ImageView) view.findViewById ( R.id.deletebutton );

            animation = AnimationUtils.loadAnimation ( getApplicationContext (), R.anim.blinking );
            any_name.setVisibility ( view.VISIBLE );
            any_name.startAnimation ( animation );


            final String realid = countid.getText ().toString ();
            final String realcounting = count_counting.getText ().toString ();
            final String realname = any_name.getText ().toString ();

            Intent intent = new Intent ( getApplicationContext (), MainActivity.class );
            intent.putExtra ( "Id", realid );
            intent.putExtra ( "real_counting", realcounting );
            intent.putExtra ( "real_name", realname );
            startActivity ( intent );
        }

} );

最佳答案

要使其他视图在单击其他视图时不再被打勾,请让您的ListAdapter存储应该打勾的视图的引用,然后在notifyDataSetInvalidated函数中在其上调用onItemClicked

要使其在离开活动时持续存在:

在活动中创建一个类变量,以记住应在哪个项目上打勾,然后在返回活动时可以使用onSaveInstanceState还原该项目。

如果您希望状态在用户关闭应用程序并返回时仍然存在,则可以将变量保存到Preferences对象。

10-08 03:43