进度dailog没有在棒棒糖中显示

时间:2016-05-21 10:02:32

标签: android xml android-layout

我正在将进度条添加到我的活动中。我的目标是实现加载进度条,直到从Web获取数据。所以我在我的布局中编写了这些代码。

  

question_activity:

$delete_post = @$_POST['form-wallpostdelete']; //Form variable

if($delete_post) {
    echo "Deleted";
}
?>
  

和QuestionActivity:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.majid.whiteboard.activities.QuestionActivity">

    <LinearLayout
        android:id="@+id/linear_container_progress_question"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:orientation="vertical"
        android:visibility="gone">

        <ProgressBar
            android:id="@+id/prg_loading_question"
            android:layout_width="50dp"
            android:layout_height="50dp" />

    </LinearLayout>

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar_question_activity"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/colorPrimary"
        app:titleTextColor="#fff" />


    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_ac_question"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/toolbar_question_activity" />

</RelativeLayout>

我将xml中的LinearLayout设置为Visible.Gone,并将其设置为

中的活动

onCreate将其设置为@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_question); initToolbar(); //Dialog initialization=========================================== final LinearLayout linearLayoutManagerProgressQuestion = (LinearLayout)findViewById(R.id.linear_container_progress_question); linearLayoutManagerProgressQuestion.setVisibility(View.VISIBLE); //Bundle Initialization ========================================= Bundle bundle = getIntent().getExtras(); if (bundle != null) { faslId = bundle.getString("FASLID"); BaseUrl = bundle.getString("BASEURL"); } //RecyclerView Initialization ====================================== recyclerQuestion = (RecyclerView) findViewById(R.id.recycler_ac_question); recyclerQuestion.setHasFixedSize(true); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(QuestionActivity.this); recyclerQuestion.setLayoutManager(linearLayoutManager); adapterRecyclerQuestion = new AdapterRecyclerQuestion(QuestionActivity.this, questionha); recyclerQuestion.setAdapter(adapterRecyclerQuestion); // ========================== Sending FirstJsonRequest ================================= FirstUrl = BaseUrl + faslId; JsonObjectRequest request = new JsonObjectRequest(FirstUrl, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { if (response != null || response.length() > 0) { try { JSONArray data = response.getJSONArray("data"); for (int i = 0; i < data.length(); i++) { JSONObject currentData = data.getJSONObject(i); ModelQuestion newModelQuestion = new ModelQuestion(); newModelQuestion.setQuestionDate(currentData.getString("date")); newModelQuestion.setQuestionDownFileName(currentData.getString("filename")); questionha.add(newModelQuestion); } afterUrl = response.getString("pagination"); } catch (JSONException e) { e.printStackTrace(); } adapterRecyclerQuestion.notifyDataSetChanged(); linearLayoutManagerProgressQuestion.setVisibility(View.GONE); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { error.printStackTrace(); linearLayoutManagerProgressQuestion.setVisibility(View.GONE); } }); AppController.getInstance().addToRequestQueue(request); 并在adapter.notifyDataSetChanged()

之后设置

View.VISIBLE。在棒棒糖前设备中,每件事都是View.Gone,但是进步

在Lollipop设备中不显示。

0 个答案:

没有答案