在安卓系统的自动完成文本视图中动态表格布局

问题描述 投票:0回答:1

嗨,在下面实现了动态表布局与标题名称固定.以同样的方式实现了自动完成文本视图。

现在想把这两个结合成单一的实现。

谁能帮帮我。

预期的输出。

Product Name           Quantity           Unit Price         Total
Autocompletetextview   dynamically want to change remaining tabel rows data 

Java。

 TableRow tbrow0 = new TableRow(getContext());
                Resources resource = getContext().getResources();
                tbrow0.setLayoutParams(getLayoutParams());
                tbrow0.addView(getTextView(0, "Product Name", Color.WHITE, Typeface.NORMAL, resource.getColor(R.color.tabs1)));
                tbrow0.addView(getTextView(0, "Quantity", Color.WHITE, Typeface.NORMAL,resource.getColor(R.color.tabs1)));
                tbrow0.addView(getTextView(0, "Unit Price", Color.WHITE, Typeface.NORMAL, resource.getColor(R.color.tabs1)));
                tbrow0.addView(getTextView(0, "Total", Color.WHITE, Typeface.NORMAL, resource.getColor(R.color.tabs1)));
                stk.addView(tbrow0,getLayoutParams());
            ArrayAdapter<String> adapter = new ArrayAdapter<String>(getContext(),android.R.layout.simple_list_item_1, product_name);
            autoproduct_name.setAdapter(adapter);
            autoproduct_name.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                    if(position+1 > 0) {


                        RecordsProducts records = recordsListProduct.get(position);
                        product_id = records.getId();
//                                                Toast.makeText
//                                                        (getContext(), "Selected : " + product_id, Toast.LENGTH_SHORT)
//                                                        .show();
                        Log.e("product_id", product_id);
                        productname = records.getProductname();
                        autoproduct_name.setText(productname);
  getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
                    }
                }
                @Override
                public void onNothingSelected(AdapterView<?> parent) {
                }
            });
android android-tablelayout
1个回答
0
投票

我有一个代码就是这样做的,因为它有点长,我认为不会是合适的,把它全部放在这里,我将分享一个链接。基本上我所做的是创建一个片段,其中我有这个 TextViewTableView 在它的下面,我用我得到的文本和位置交互式地填充(因为它是一个位置自动完成)。

https:/github.comeduasincoMeetEattreemasterappsrcmainjavacomcomeaquieduardorodriguezcomeaquiutilitiesplace_autocomplete。

© www.soinside.com 2019 - 2024. All rights reserved.