View.Visible
工作正常以上版本5.0在android但不工作在Kitkat版本。沒有得到實際的問題,我搜了很多,但沒有得到解決方案以下是我的代碼。謝謝你在前進View.Visible工作正常在棉花糖但不工作Kikat
public class mainActivity extends AppCompatActivity implements View.OnClickListener {
Button button1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_stb_commands);
button1 = (Button)findViewById(R.id.button1);
button1.setOnClickListener(this);
button1.setVisibility(View.GONE);
}
@Override
public void onClick(View view) {
switch (view.getId()){
case R.id.button1:
HashMap data = new HashMap();
new mainActivity.AsyncTaskGenre(data).execute();
break;
}
}
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(mainActivity.this);
pDialog.setMessage("Loading...");
pDialog.show();
}
@Override
protected String doInBackground(Void... params) {
String request = "http://";
try {
JSONObject json = jsonParser.makeHttpRequest(request, "POST",data);
return json.toString();
} catch (Exception e){
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
pDialog.dismiss();
Log.d("RESULT ",""+s);
if (s != null) {
try {
JSONObject jsonObject = new JSONObject(s);
String error = jsonObject.get("error").toString();
Log.d("RESULT", " " +error);
if (error.equals("false"))
{
button1.setVisibility(View.VISIBLE);
}
else
{
Toast.makeText(getApplicationContext(),"not found...!",Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
else{
Toast.makeText(getApplicationContext(),"check connection...!",Toast.LENGTH_LONG).show();
}
}
}
它應該爲Android的每一個版本而消失,因爲你的代碼告訴你要做那個button1.setVisibility(View.GONE);在onCreate – sadat
錯誤的編碼比較'if(error ==「false」)' – Piyush