如果 textview 为空,如何启动 activity?

How to start activity if textview is empty?

在下面给出的代码中,我基本上使用了get()方法并显示了TextView中的数据,如果TextView我想开始另一个activity是空的,我已经尝试了很多选项,但就是行不通。

Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(url)
                .addConverterFactory(GsonConverterFactory.create())
                .build();

Map<String, String> params = new HashMap<String, String>();
params.put("Content-Type", "application/json");
SharedPreferences p = getActivity().getSharedPreferences("secret", Context.MODE_PRIVATE);
String token = p.getString("token", "");
params.put("Authorization", "Token " + token);


PlaceHolderApi placeHolderApi = retrofit.create(PlaceHolderApi.class);
        Call<List<profileDetails>> call=placeHolderApi.getDetails(params);
        call.enqueue(new Callback<List<profileDetails>>() {
            @Override
            public void onResponse(Call<List<profileDetails>> call, Response<List<profileDetails>> response) {
                List<profileDetails> data=response.body();
                for (int i=0; i<data.size();i++){
                    name.append(""+data.get(i).getFullname());

                    age.append(""+data.get(i).getAge());

                    address.append("Address: "+data.get(i).getLocation());

                    gender.append("Gender: "+data.get(i).getGender());

                    num.append("Number: "+data.get(i).getPhone_number());

                    uId.append("Id: "+data.get(i).getId());

                    RoomId = Integer.parseInt(data.get(i).getId());}

            }

            @Override
            public void onFailure(Call<List<profileDetails>> call, Throwable t) {
                Log.e("kk","lal"+t);
                Toast.makeText(getContext(),"Error Cause : "+t,Toast.LENGTH_LONG).show();
            }
        });
    }

不清楚你已经尝试过什么,但让我给你一个简单的解决方案,你可以检查一下

you_textview.setText("your text from server")

if(your_textview.getText().toString().isEmpty())
{
  startActivity(new Intent(this,MainActivity.class));  
}