在android中设置View的文本?

时间:2013-07-09 12:51:48

标签: android view textview

我想针对视图“text”设置文本....但是settext不能从这里获得任何sujjestion请.... ????

   ArrayAdapter<String> adapter = new ArrayAdapter<String>(MembersdealStream_Modified.this,
                        R.layout.membersdeal_streampagepage_singlerow, R.id.tv_membersdeal_streampagepage_header, targetArray) {
                    @Override
                    public View getView(int position, View convertView, ViewGroup parent) {
                        View row = super.getView(position, convertView, parent);


                        View text = row.findViewById(R.id.tv_membersdeal_streampagepage_description);
                        text.setTag(position); 


                        text.setOnClickListener(MembersdealStream_Modified.this);


                        return row;
                    }
                };

我想做像

这样的事情
text.setText("Anything.....");`

1 个答案:

答案 0 :(得分:2)

如果R.id.tv_membersdeal_streampagepage_descriptionTextView,请替换:

View text = row.findViewById(R.id.tv_membersdeal_streampagepage_description);

使用:

TextView text = (TextView)row.findViewById(R.id.tv_membersdeal_streampagepage_description);

setText()TextView上的方法,而不是View上的方法。