我想添加带有数据库数据和可点击的动态文本视图



我想添加动态textView,它保存数据库中的数据。当我单击"添加"按钮时,它将打开下一个活动并将textField数据输入数据库,然后返回到主活动并将插入的数据添加到可单击的文本视图中(当单击该文本时,再次以可编辑的形式打开活动并更新该数据)///

我在textView中获得了动态数据,但我想点击(打开到新的意图中)该相关项目,这样我就可以将相关项目更新到数据库中

 protected void onActivityResult(int requestCode, int resultCode, Intent intentData) {
        super.onActivityResult(requestCode, resultCode, intentData);
        switch (requestCode) {
        case (100):
        {
            String currentId=intentData.getStringExtra(AddInvoiceItem.ItemId);
            String itemName=intentData.getStringExtra(AddInvoiceItem.ItemName);
                        customerNotes.setText(itemName);
LinearLayout ll = (LinearLayout) findViewById(R.id.linearLayoutItem);
            TextView tv = new TextView(this);
            tv.setText(itemName);
            ll.addView(tv);
}
final LinearLayout ll = (LinearLayout) findViewById(R.id.linearLayoutItem);
    //LinearLayout layoutSection = new LinearLayout(this);
final   RelativeLayout rl = new RelativeLayout(this);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                                LinearLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    RelativeLayout.LayoutParams paramss = new RelativeLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    //params.gravity = Gravity.CENTER;
    params.setMargins(50,0,0,0);// left, top, right, bottom
    paramss.setMargins(400, 0, 0, 0);
    params.height=60;
    params.width=200;
    final   ImageView imageView=new ImageView(this);
    imageView.setImageResource(R.drawable.remove);

final   TextView textView = new TextView(this);
final       TextView tv=new TextView(this);
    textView.setLayoutParams(params);
    tv.setLayoutParams(paramss);
    textView.setText(itemName);
    textView.setTextSize(18);
    tv.setText(total);
    ll.addView(rl);
    rl.addView(imageView);
    rl.addView(textView);
    rl.addView(tv);
textView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                  Intent updateItem=new Intent(this,second.class);
                              updateItem.putExtra("type","item");

            this.startActivityForResult(updateItem, 100);
            }
        });
        }

根据您的要求将其放入onActivityResult i代码中。。

相关内容

  • 没有找到相关文章

最新更新