Textview显示“ android.support.v7.widget.appcompattextview {f17ebd0 v.ED ....”

时间:2019-01-09 07:34:39

标签: android android-studio textview

大家好,我的textview(txtShOW)中出现了此错误,该错误在onclicklistener内显示为android.support.v7.widget.appcompattextview {f17ebd0 v.ED....。而且我还从空字符串中获取了字符串titlefromURL,如何删除字符串中的空?谢谢。

public class HomeFragmentTwo extends Fragment {

TextView txtSHOW;
String URLTitle = "NAMEURL";
String titlefromURL;

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.activity_home_fragment_two, null);


    txtSHOW = rootView.findViewById(R.id.txt_SHOW);
    txtSHOW.setText(titlefromURL);

    Button btnClick = rootView.findViewById(R.id.btn_Click);
    btnClick.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
                if(connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED) {

                    AlertDialog.Builder alertInstalled = new AlertDialog.Builder(getActivity());
                    alertInstalled.setMessage("WiFi IP Address " + ipString);
                    alertInstalled.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            getWebsite();
                            if(URLTitle.equals(txtSHOW)){
                                Toast.makeText(getActivity(), "OKAY" , Toast.LENGTH_LONG).show();
                            }
                            else{
                                AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
                                alertDialog.setTitle("Alert");
                                alertDialog.setMessage("SHOW" + txtSHOW);
                                alertDialog.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                    }
                                });
                                alertDialog.show();
                            }
                        }
                    });
                    alertInstalled.show();
                }
                else {

                }
            }
        }
    });

    return rootView;
}


private void getWebsite() {
    new Thread(new Runnable() {
        @Override
        public void run() {
            final StringBuilder builder = new StringBuilder();

            try {
                Document doc = Jsoup.connect("google.com/sampleURL").get();
                titlefromURL = doc.title();

                builder.append(titlefromURL).append("\n");

            } catch (IOException e) {
                builder.append("Error : ").append(e.getMessage()).append("\n");
            }
        }
    }).start();
}

}

我希望String titlefromURL的输出将是jsoup中文档的标题,但实际提供给我的输出为null。而且TextView也输出为android.support.v7.widget.appcompattextview {f17ebd0 v.ED,这也是一个错误。

0 个答案:

没有答案