-1
リストビューに何も表示されません。ただし、遅延を追加しないでください。約1秒間遅延を追加すると、リストビューの結果がscreen.Itsで表示されます。このように私はアンドロイド7.1のコードを実行すると、それは私がトーストで見ることができるように、データがサーバーから受信されている間、画面上に何も表示されません。リストビューがアンドロイドで正常に動作しない
Entry1.xml(カスタムアダプター)
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="13dp"
android:focusable="false"
android:focusableInTouchMode="false"
>
<ImageView
android:layout_width="90dp"
android:layout_height="50dp"
android:src="@drawable/image"
android:layout_gravity="center"
android:focusable="false"
android:focusableInTouchMode="false"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:focusable="false"
android:focusableInTouchMode="false"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:focusable="false"
android:focusableInTouchMode="false">
<TextView
android:layout_width="100dp"
android:layout_height="match_parent"
android:text="Name"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="14dp"
android:focusable="false"
android:focusableInTouchMode="false"/>
<TextView
android:id="@+id/name2"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:textAlignment="center"
android:layout_marginLeft="15dp"
android:background="#00000000"
android:letterSpacing="0.1"
android:textSize="16dp"
android:inputType="text"
android:textColor="@color/black"
android:focusable="false"
android:focusableInTouchMode="false"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:focusable="false"
android:focusableInTouchMode="false">
<TextView
android:layout_width="100dp"
android:layout_height="match_parent"
android:text="Company Name"
android:textColor="@color/black"
android:textSize="14dp"
android:textAlignment="center"
android:focusable="false"
android:focusableInTouchMode="false"/>
<TextView
android:id="@+id/cname2"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:textAlignment="center"
android:layout_marginLeft="15dp"
android:background="#00000000"
android:letterSpacing="0.1"
android:textSize="16dp"
android:inputType="text"
android:textColor="@color/black"
android:focusable="false"
android:focusableInTouchMode="false"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:focusable="false"
android:focusableInTouchMode="false">
<TextView
android:layout_width="100dp"
android:layout_height="match_parent"
android:text="Position"
android:textColor="@color/black"
android:textSize="14dp"
android:textAlignment="center"
android:focusable="false"
android:focusableInTouchMode="false"/>
<TextView
android:id="@+id/pos2"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:textAlignment="center"
android:layout_marginLeft="15dp"
android:background="#00000000"
android:letterSpacing="0.1"
android:textSize="16dp"
android:inputType="text"
android:textColor="@color/black"
android:focusable="false"
android:focusableInTouchMode="false"
/>
</LinearLayout>
</LinearLayout>
Card.xml(主活動)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rlLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.hppc.business.Card">
<ListView
android:id="@+id/lvUsers"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:clickable="true"
android:focusable="false"
android:focusableInTouchMode="false"
android:descendantFocusability="blocksDescendants">
</ListView>
mainactivity.java
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
employee_id = getIntent().getStringExtra("employee_id");
//Toast.makeText(getApplicationContext(),answer,Toast.LENGTH_SHORT).show();
requestQueue1 = Volley.newRequestQueue(this);
doit_function();
setContentView(R.layout.activity_card);
listView = (ListView) findViewById(R.id.lvUsers);
listView.setClickable(true);
populateUsersList();
}
私はRecyclerビューも試しましたが、同じ問題があります。 – himanshu
最初に静的な値を追加して、結果、成功または失敗を確認しますか? @himanshu –
静的なデータは、リストビューとリサイクラビューでも動作しますが、サーバからデータを取得しようとすると、そのどれも動作しません。私が観察した別の奇妙なことは、カメラIntentを開いて閉じると、データが画面に表示されるということです。 – himanshu