簡體   English   中英

android 中的自動完成 textview 中的動態表布局

[英]dynamic table layout inside autocomplete textview in android

嗨,在下面用 header 名稱實現的動態表布局是固定的。以同樣的方式實現自動完成 textview。

現在想將這兩者組合成一個實現。

誰能幫我。

預期 output:

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) {
                }
            });

我有一個代碼可以做到這一點,因為它有點長,我認為把它全部放在這里不合適,我將分享一個鏈接。 基本上我所做的是創建一個片段,其中我有這個TextViewTableView ,我用我得到的文本和位置交互填充(因為它是一個位置自動完成)。

https://github.com/eduasinco/MeetEat/tree/master/app/src/main/java/com/comeaqui/eduardorodriguez/comeaqui/utilities/place_autocomplete

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM