将值更新为哈希表?

时间:2012-03-12 15:31:34

标签: android

我在将值更新为hash-table时遇到了一些问题,这是我的问题,我会清楚地解释它。

1.我从服务器获得响应,我通过布局Layout-Inflater将值添加到布局中。 2.在我们的应用程序中,我们有流请求。当流请求打开时,值需要定期更新。

在哈希表中存储值

Hashtable<String, View> indicesHashtable = new Hashtable<String, View>();

对于(步骤1)代码,我写在代码下面。

private void addIndices(LinearLayout parent, final String key,final String value) {

        LayoutInflater factory = LayoutInflater.from(mContext);
        final View row = factory.inflate(R.layout.indices_values, null);
        final TextView keyTextView = (TextView) row.findViewById(R.id.txtCompany);
        final TextView valueTextView = (TextView) row.findViewById(R.id.txtIndex);
        final Button iconImageView = (Button) row.findViewById(R.id.btnIcon);

        row.setBackgroundResource(android.R.drawable.list_selector_background);

        if (value.length() > 0) {
            keyTextView.setText(Html.fromHtml("<b>"+indices.get(key)+"</b>"));
            valueTextView.setText(Html.fromHtml(value));

            if(quoteArrowIconId != -1)
                iconImageView.setBackgroundResource(quoteArrowIconId);
            else
                iconImageView.setBackgroundDrawable(null);
        }else{
            keyTextView.setText(Html.fromHtml(key));
        }

        indicesHashtable.put(key, row);
        parent.addView(row);
    }

对于(步骤2),我需要你们的帮助。

我已经编写了代码..我已在下面显示。

private void handleResponseOfResponses(ResponseParser response) {

        Hashtable responses = (Hashtable) response.getValue(Response_890.RESPONSES);

        String[] symbols = new String[responses.size()];
        int index = 0;
        indicesHashtable.clear();
        for(int i =indicesSymbols.length-1; i >= 0; i--){

            Enumeration e = responses.keys();


            while (e.hasMoreElements()) {

                ResponseParser subResponse = (ResponseParser) responses.get(e.nextElement());
                if (subResponse.getResponseCode() == ResponseCodes.QUOTES_RESPONSE) {

                    String[] quoteProperties = (String[]) subResponse.getValue(Response_312.QUOTES_KEY);

                    if(quoteProperties[0].equalsIgnoreCase(indicesSymbols[i])){

//                      symbolTable.put(quoteProperties[0].toUpperCase(), index);
                        symbols[index++] = quoteProperties[0];

                        String value = quoteValue(quoteProperties);
For displaying the  values coming for response i have added (AddIndices)method
                        addIndices(linear_Indices, quoteProperties[0], value);

                    }
                }               
            }   
        }
        autoscroll();
        indicesStreamerClient =  new StreamerClient(indicesSymbols){

            @Override
            public void onStreamDataReceived(QuoteData quoteData) {

                System.out.println("onStreamDataReceived () -> "+quoteData.getSymbol());
                HERE I NEED TO ADDED ANOTHER METHOD FOR UPDATING THE VALUES..HOW I CAN WRITE THE CODE.
            };
        };

        Streamer.getInstance(mContext).registerStramerClient(indicesStreamerClient);
    }

伙计们,我和新人一样新鲜。

提前致谢!!!!!!

0 个答案:

没有答案
相关问题