在此应用程序中,用户将输入项目详细信息并将其保存在SQLite数据库中。并在回收站视图中显示已保存的项目。现在我需要添加更多两个功能。首先是从列表项进行搜索。其次是使项目可单击,以便在单击项目时,它将进入详细信息视图活动。这是我的ItemListActivity java类文件
package com.example.autoparts;
public class ItemListActivity extends AppCompatActivity {
Context context = ItemListActivity.this;
private RecyclerView itemsRecycler;
private ArrayList<Items> listItems;
private SearchView iSearchView;
private SearchManager manager;
//To customize the layout property
private RecyclerView.LayoutManager itemLayoutManager;
//calling the ItemAdapter
private ItemAdapter itemAdapter;
//calling the dbhelper class
PartsDbHelper dbHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_item_list);
//Recycler View for items to display
itemsRecycler = (RecyclerView) findViewById(R.id.items_recycler_view);
dbHelper = new PartsDbHelper(this);
manager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
//set the fixed size of the RecyclerView
itemsRecycler.setHasFixedSize(true);
//setting Linear as layout
itemsRecycler.setLayoutManager(new LinearLayoutManager(this));
itemAdapter = new ItemAdapter(listItems, this);
generateObjects();
getItemsFromSQLite();
}
private void generateObjects() {
listItems = new ArrayList<>();
itemAdapter = new ItemAdapter(listItems, this);
RecyclerView.LayoutManager layoutManager = new
LinearLayoutManager(getApplicationContext());
itemsRecycler.setLayoutManager(layoutManager);
itemsRecycler.setAdapter(itemAdapter);
dbHelper = new PartsDbHelper(this);
}
富国沪深
慕容708150
相关分类