Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/218.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android ListView未出现在“活动”中_Android_Android Listview - Fatal编程技术网

Android ListView未出现在“活动”中

Android ListView未出现在“活动”中,android,android-listview,Android,Android Listview,我正在制作一个应用程序,其中我希望使用PHPMYADMIN中的服务器在列表视图中向用户显示所有以前的订单详细信息 问题:未在活动中获取ListView,获取空白活动而不是ListView OrdersAdapter.java: public class OrdersAdapter extends BaseAdapter { TextView tName,tId,tOid ; String MemberID,resultServer,strMemberID,strName,str

我正在制作一个应用程序,其中我希望使用PHPMYADMIN中的服务器在列表视图中向用户显示所有以前的订单详细信息

问题:未在活动中获取ListView,获取空白活动而不是ListView

OrdersAdapter.java:

public class OrdersAdapter extends BaseAdapter {

    TextView tName,tId,tOid ;
    String MemberID,resultServer,strMemberID,strName,strOrderID;

    Activity activity;
    LayoutInflater inflater;
    ListView listView;


    public OrdersAdapter(Activity a) {
        // TODO Auto-generated constructor stub
        activity = a;
        inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    }

    public int getCount() {
        return 0;
        // TODO Auto-generated method stub

    }

    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

        public View getView(final int position, View convertView, ViewGroup parent) {
            // TODO Auto-generated method stub
            View vi = convertView;
            if (convertView == null)
                vi = inflater.inflate(R.layout.listrow_orders, null);  // listrow_cart

            // Permission StrictMode
            if (android.os.Build.VERSION.SDK_INT > 9) {
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);


            tId = (TextView)activity.findViewById(R.id.txtTotalAmount);
            tName = (TextView)activity.findViewById(R.id.txtItemDetails);

            String url = "http://172.16.0.4/res/order_fetch.php";
            Intent intent= activity.getIntent();
            MemberID = intent.getStringExtra("MemberID");
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("sMemberID", MemberID));
            resultServer  = getHttpPost(url,params);

            strMemberID = "";
            strName = "";


            JSONObject c;
            try {
                c = new JSONObject(resultServer);
                strMemberID = c.getString("TotalAmount");               
                strName = c.getString("ItemDetails");

                if(!strMemberID.equals(""))
                    {                   
                        tName.setText(strName);
                        tId.setText(strMemberID);               
                    }
                    else
                    {               
                        tName.setText("-");
                        tId.setText("-");
                    }
                    } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    }       

                }
            return vi;
        }       

                String getHttpPost(String url,List<NameValuePair> params) {
                StringBuilder str = new StringBuilder();
                HttpClient client = new DefaultHttpClient();
                HttpPost httpPost = new HttpPost(url);

                try {
                    httpPost.setEntity(new UrlEncodedFormEntity(params));
                    HttpResponse response = client.execute(httpPost);
                    StatusLine statusLine = response.getStatusLine();
                    int statusCode = statusLine.getStatusCode();
                    if (statusCode == 200) { // Status OK
                        HttpEntity entity = response.getEntity();
                        InputStream content = entity.getContent();
                        BufferedReader reader = new BufferedReader(new InputStreamReader(content));
                        String line;
                        while ((line = reader.readLine()) != null) {
                            str.append(line);
                        }
                    } else {
                        Log.e("Log", "Failed to download result..");
                    }
                } catch (ClientProtocolException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                return str.toString();  
        }

}
    public class OrdersActivity extends Activity 
{               
    ListView mLstView1;
    OrdersAdapter mViewOrdersAdpt;

    @SuppressLint("NewApi")
    @Override

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_orders);   

         mLstView1 = (ListView) findViewById(R.id.listView1);

            mViewOrdersAdpt = new OrdersAdapter(OrdersActivity.this);
            mLstView1.setAdapter(mViewOrdersAdpt);

            mLstView1.setOnItemClickListener(new OnItemClickListener() {

                 public void onItemClick(AdapterView<?> parent, View v,
                         final int position, long id) 
                 {       

                }
            }); 
    }
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ffffff" >

    <include
        android:id="@+id/header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        layout="@layout/header_orders" />

<ListView 
    android:layout_width="match_parent" 
    android:id="@+id/listView1" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_below="@+id/header" 
    android:cacheColorHint="#00000000" 
    android:divider="#b5b5b5" 
    android:dividerHeight="1dp" 
    android:layout_alignParentBottom="true" />

</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="5dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="5dp"
    android:background="@drawable/btn_background"
    android:orientation="horizontal"
    android:padding="5dip" >

<TextView
    android:id="@+id/txtTotalAmount"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView1"
    android:layout_below="@+id/textView1"
    android:textColor="#a60704"
    android:text="TextView" />

<TextView
    android:id="@+id/txtItemDetails"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView3"
    android:layout_below="@+id/textView3"
    android:textColor="#a60704"
    android:text="Item Details Here" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/txtTotalAmount"
    android:layout_below="@+id/txtTotalAmount"
    android:layout_marginTop="17dp"
    android:text="Ordered Items:"
    android:textColor="#a60704"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text="Total Amount"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="#a60704" />

</RelativeLayout>
公共类OrdersAdapter扩展BaseAdapter{
text视图tName、tId、tOid;
字符串MemberID、resultServer、strMemberID、strName、strOrderID;
活动;
充气机;
列表视图列表视图;
公共秩序助理(活动a){
//TODO自动生成的构造函数存根
活动=a;
充气器=(LayoutInflater)activity.getSystemService(Context.LAYOUT\u充气器\u SERVICE);
}
public int getCount(){
返回0;
//TODO自动生成的方法存根
}
公共对象getItem(int位置){
//TODO自动生成的方法存根
返回位置;
}
公共长getItemId(int位置){
//TODO自动生成的方法存根
返回位置;
}
公共视图getView(最终整数位置、视图转换视图、视图组父视图){
//TODO自动生成的方法存根
视图vi=转换视图;
if(convertView==null)
vi=充气机。充气(R.layout.listrow_orders,null);//listrow_cart
//权限限制模式
如果(android.os.Build.VERSION.SDK_INT>9){
StrictMode.ThreadPolicy policy=新建StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(策略);
tId=(TextView)activity.findViewById(R.id.txtTotalAmount);
tName=(TextView)activity.findViewById(R.id.txtItemDetails);
字符串url=”http://172.16.0.4/res/order_fetch.php";
Intent=activity.getIntent();
MemberID=intent.getStringExtra(“MemberID”);
List params=new ArrayList();
添加(新的BasicNameValuePair(“sMemberID”,MemberID));
resultServer=getHttpPost(url,参数);
strMemberID=“”;
strName=“”;
JSONObject c;
试一试{
c=新的JSONObject(resultServer);
strMemberID=c.getString(“TotalAmount”);
strName=c.getString(“ItemDetails”);
如果(!strMemberID.equals(“”)
{                   
tName.setText(strName);
tId.setText(strMemberID);
}
其他的
{               
tName.setText(“-”);
tId.setText(“-”);
}
}捕获(JSONException e){
//TODO自动生成的捕捉块
e、 printStackTrace();
}       
}
返回vi;
}       
字符串getHttpPost(字符串url,列表参数){
StringBuilder str=新的StringBuilder();
HttpClient=new DefaultHttpClient();
HttpPost HttpPost=新的HttpPost(url);
试一试{
setEntity(新的UrlEncodedFormEntity(参数));
HttpResponse response=client.execute(httpPost);
StatusLine StatusLine=response.getStatusLine();
int statusCode=statusLine.getStatusCode();
如果(statusCode==200){//状态正常
HttpEntity=response.getEntity();
InputStream内容=entity.getContent();
BufferedReader=新的BufferedReader(新的InputStreamReader(内容));
弦线;
而((line=reader.readLine())!=null){
str.append(行);
}
}否则{
Log.e(“日志”,“下载结果失败…”);
}
}捕获(客户端协议例外e){
e、 printStackTrace();
}捕获(IOE异常){
e、 printStackTrace();
}
return str.toString();
}
}
OrdersActivity.java:

public class OrdersAdapter extends BaseAdapter {

    TextView tName,tId,tOid ;
    String MemberID,resultServer,strMemberID,strName,strOrderID;

    Activity activity;
    LayoutInflater inflater;
    ListView listView;


    public OrdersAdapter(Activity a) {
        // TODO Auto-generated constructor stub
        activity = a;
        inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    }

    public int getCount() {
        return 0;
        // TODO Auto-generated method stub

    }

    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

        public View getView(final int position, View convertView, ViewGroup parent) {
            // TODO Auto-generated method stub
            View vi = convertView;
            if (convertView == null)
                vi = inflater.inflate(R.layout.listrow_orders, null);  // listrow_cart

            // Permission StrictMode
            if (android.os.Build.VERSION.SDK_INT > 9) {
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);


            tId = (TextView)activity.findViewById(R.id.txtTotalAmount);
            tName = (TextView)activity.findViewById(R.id.txtItemDetails);

            String url = "http://172.16.0.4/res/order_fetch.php";
            Intent intent= activity.getIntent();
            MemberID = intent.getStringExtra("MemberID");
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("sMemberID", MemberID));
            resultServer  = getHttpPost(url,params);

            strMemberID = "";
            strName = "";


            JSONObject c;
            try {
                c = new JSONObject(resultServer);
                strMemberID = c.getString("TotalAmount");               
                strName = c.getString("ItemDetails");

                if(!strMemberID.equals(""))
                    {                   
                        tName.setText(strName);
                        tId.setText(strMemberID);               
                    }
                    else
                    {               
                        tName.setText("-");
                        tId.setText("-");
                    }
                    } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    }       

                }
            return vi;
        }       

                String getHttpPost(String url,List<NameValuePair> params) {
                StringBuilder str = new StringBuilder();
                HttpClient client = new DefaultHttpClient();
                HttpPost httpPost = new HttpPost(url);

                try {
                    httpPost.setEntity(new UrlEncodedFormEntity(params));
                    HttpResponse response = client.execute(httpPost);
                    StatusLine statusLine = response.getStatusLine();
                    int statusCode = statusLine.getStatusCode();
                    if (statusCode == 200) { // Status OK
                        HttpEntity entity = response.getEntity();
                        InputStream content = entity.getContent();
                        BufferedReader reader = new BufferedReader(new InputStreamReader(content));
                        String line;
                        while ((line = reader.readLine()) != null) {
                            str.append(line);
                        }
                    } else {
                        Log.e("Log", "Failed to download result..");
                    }
                } catch (ClientProtocolException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                return str.toString();  
        }

}
    public class OrdersActivity extends Activity 
{               
    ListView mLstView1;
    OrdersAdapter mViewOrdersAdpt;

    @SuppressLint("NewApi")
    @Override

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_orders);   

         mLstView1 = (ListView) findViewById(R.id.listView1);

            mViewOrdersAdpt = new OrdersAdapter(OrdersActivity.this);
            mLstView1.setAdapter(mViewOrdersAdpt);

            mLstView1.setOnItemClickListener(new OnItemClickListener() {

                 public void onItemClick(AdapterView<?> parent, View v,
                         final int position, long id) 
                 {       

                }
            }); 
    }
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ffffff" >

    <include
        android:id="@+id/header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        layout="@layout/header_orders" />

<ListView 
    android:layout_width="match_parent" 
    android:id="@+id/listView1" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_below="@+id/header" 
    android:cacheColorHint="#00000000" 
    android:divider="#b5b5b5" 
    android:dividerHeight="1dp" 
    android:layout_alignParentBottom="true" />

</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="5dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="5dp"
    android:background="@drawable/btn_background"
    android:orientation="horizontal"
    android:padding="5dip" >

<TextView
    android:id="@+id/txtTotalAmount"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView1"
    android:layout_below="@+id/textView1"
    android:textColor="#a60704"
    android:text="TextView" />

<TextView
    android:id="@+id/txtItemDetails"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView3"
    android:layout_below="@+id/textView3"
    android:textColor="#a60704"
    android:text="Item Details Here" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/txtTotalAmount"
    android:layout_below="@+id/txtTotalAmount"
    android:layout_marginTop="17dp"
    android:text="Ordered Items:"
    android:textColor="#a60704"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text="Total Amount"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="#a60704" />

</RelativeLayout>
公共类OrdersActivity扩展活动
{               
列表视图mLstView1;
订单适配器mViewOrdersAdpt;
@SuppressLint(“新API”)
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_orders);
mLstView1=(ListView)findViewById(R.id.listView1);
mViewOrdersAdpt=newordersadapt(OrdersActivity.this);
mLstView1.setAdapter(mViewOrdersAdpt);
mLstView1.setOnItemClickListener(新的OnItemClickListener(){
public void onItemClick(AdapterView父视图、视图v、,
最终整数位置,长id)
{       
}
}); 
}
}
activity\u orders.xml:

public class OrdersAdapter extends BaseAdapter {

    TextView tName,tId,tOid ;
    String MemberID,resultServer,strMemberID,strName,strOrderID;

    Activity activity;
    LayoutInflater inflater;
    ListView listView;


    public OrdersAdapter(Activity a) {
        // TODO Auto-generated constructor stub
        activity = a;
        inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    }

    public int getCount() {
        return 0;
        // TODO Auto-generated method stub

    }

    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

        public View getView(final int position, View convertView, ViewGroup parent) {
            // TODO Auto-generated method stub
            View vi = convertView;
            if (convertView == null)
                vi = inflater.inflate(R.layout.listrow_orders, null);  // listrow_cart

            // Permission StrictMode
            if (android.os.Build.VERSION.SDK_INT > 9) {
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);


            tId = (TextView)activity.findViewById(R.id.txtTotalAmount);
            tName = (TextView)activity.findViewById(R.id.txtItemDetails);

            String url = "http://172.16.0.4/res/order_fetch.php";
            Intent intent= activity.getIntent();
            MemberID = intent.getStringExtra("MemberID");
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("sMemberID", MemberID));
            resultServer  = getHttpPost(url,params);

            strMemberID = "";
            strName = "";


            JSONObject c;
            try {
                c = new JSONObject(resultServer);
                strMemberID = c.getString("TotalAmount");               
                strName = c.getString("ItemDetails");

                if(!strMemberID.equals(""))
                    {                   
                        tName.setText(strName);
                        tId.setText(strMemberID);               
                    }
                    else
                    {               
                        tName.setText("-");
                        tId.setText("-");
                    }
                    } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    }       

                }
            return vi;
        }       

                String getHttpPost(String url,List<NameValuePair> params) {
                StringBuilder str = new StringBuilder();
                HttpClient client = new DefaultHttpClient();
                HttpPost httpPost = new HttpPost(url);

                try {
                    httpPost.setEntity(new UrlEncodedFormEntity(params));
                    HttpResponse response = client.execute(httpPost);
                    StatusLine statusLine = response.getStatusLine();
                    int statusCode = statusLine.getStatusCode();
                    if (statusCode == 200) { // Status OK
                        HttpEntity entity = response.getEntity();
                        InputStream content = entity.getContent();
                        BufferedReader reader = new BufferedReader(new InputStreamReader(content));
                        String line;
                        while ((line = reader.readLine()) != null) {
                            str.append(line);
                        }
                    } else {
                        Log.e("Log", "Failed to download result..");
                    }
                } catch (ClientProtocolException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                return str.toString();  
        }

}
    public class OrdersActivity extends Activity 
{               
    ListView mLstView1;
    OrdersAdapter mViewOrdersAdpt;

    @SuppressLint("NewApi")
    @Override

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_orders);   

         mLstView1 = (ListView) findViewById(R.id.listView1);

            mViewOrdersAdpt = new OrdersAdapter(OrdersActivity.this);
            mLstView1.setAdapter(mViewOrdersAdpt);

            mLstView1.setOnItemClickListener(new OnItemClickListener() {

                 public void onItemClick(AdapterView<?> parent, View v,
                         final int position, long id) 
                 {       

                }
            }); 
    }
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ffffff" >

    <include
        android:id="@+id/header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        layout="@layout/header_orders" />

<ListView 
    android:layout_width="match_parent" 
    android:id="@+id/listView1" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_below="@+id/header" 
    android:cacheColorHint="#00000000" 
    android:divider="#b5b5b5" 
    android:dividerHeight="1dp" 
    android:layout_alignParentBottom="true" />

</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="5dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="5dp"
    android:background="@drawable/btn_background"
    android:orientation="horizontal"
    android:padding="5dip" >

<TextView
    android:id="@+id/txtTotalAmount"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView1"
    android:layout_below="@+id/textView1"
    android:textColor="#a60704"
    android:text="TextView" />

<TextView
    android:id="@+id/txtItemDetails"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView3"
    android:layout_below="@+id/textView3"
    android:textColor="#a60704"
    android:text="Item Details Here" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/txtTotalAmount"
    android:layout_below="@+id/txtTotalAmount"
    android:layout_marginTop="17dp"
    android:text="Ordered Items:"
    android:textColor="#a60704"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text="Total Amount"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="#a60704" />

</RelativeLayout>

listrow\u orders.xml:

public class OrdersAdapter extends BaseAdapter {

    TextView tName,tId,tOid ;
    String MemberID,resultServer,strMemberID,strName,strOrderID;

    Activity activity;
    LayoutInflater inflater;
    ListView listView;


    public OrdersAdapter(Activity a) {
        // TODO Auto-generated constructor stub
        activity = a;
        inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    }

    public int getCount() {
        return 0;
        // TODO Auto-generated method stub

    }

    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

        public View getView(final int position, View convertView, ViewGroup parent) {
            // TODO Auto-generated method stub
            View vi = convertView;
            if (convertView == null)
                vi = inflater.inflate(R.layout.listrow_orders, null);  // listrow_cart

            // Permission StrictMode
            if (android.os.Build.VERSION.SDK_INT > 9) {
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);


            tId = (TextView)activity.findViewById(R.id.txtTotalAmount);
            tName = (TextView)activity.findViewById(R.id.txtItemDetails);

            String url = "http://172.16.0.4/res/order_fetch.php";
            Intent intent= activity.getIntent();
            MemberID = intent.getStringExtra("MemberID");
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("sMemberID", MemberID));
            resultServer  = getHttpPost(url,params);

            strMemberID = "";
            strName = "";


            JSONObject c;
            try {
                c = new JSONObject(resultServer);
                strMemberID = c.getString("TotalAmount");               
                strName = c.getString("ItemDetails");

                if(!strMemberID.equals(""))
                    {                   
                        tName.setText(strName);
                        tId.setText(strMemberID);               
                    }
                    else
                    {               
                        tName.setText("-");
                        tId.setText("-");
                    }
                    } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    }       

                }
            return vi;
        }       

                String getHttpPost(String url,List<NameValuePair> params) {
                StringBuilder str = new StringBuilder();
                HttpClient client = new DefaultHttpClient();
                HttpPost httpPost = new HttpPost(url);

                try {
                    httpPost.setEntity(new UrlEncodedFormEntity(params));
                    HttpResponse response = client.execute(httpPost);
                    StatusLine statusLine = response.getStatusLine();
                    int statusCode = statusLine.getStatusCode();
                    if (statusCode == 200) { // Status OK
                        HttpEntity entity = response.getEntity();
                        InputStream content = entity.getContent();
                        BufferedReader reader = new BufferedReader(new InputStreamReader(content));
                        String line;
                        while ((line = reader.readLine()) != null) {
                            str.append(line);
                        }
                    } else {
                        Log.e("Log", "Failed to download result..");
                    }
                } catch (ClientProtocolException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                return str.toString();  
        }

}
    public class OrdersActivity extends Activity 
{               
    ListView mLstView1;
    OrdersAdapter mViewOrdersAdpt;

    @SuppressLint("NewApi")
    @Override

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_orders);   

         mLstView1 = (ListView) findViewById(R.id.listView1);

            mViewOrdersAdpt = new OrdersAdapter(OrdersActivity.this);
            mLstView1.setAdapter(mViewOrdersAdpt);

            mLstView1.setOnItemClickListener(new OnItemClickListener() {

                 public void onItemClick(AdapterView<?> parent, View v,
                         final int position, long id) 
                 {       

                }
            }); 
    }
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ffffff" >

    <include
        android:id="@+id/header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        layout="@layout/header_orders" />

<ListView 
    android:layout_width="match_parent" 
    android:id="@+id/listView1" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_below="@+id/header" 
    android:cacheColorHint="#00000000" 
    android:divider="#b5b5b5" 
    android:dividerHeight="1dp" 
    android:layout_alignParentBottom="true" />

</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="5dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="5dp"
    android:background="@drawable/btn_background"
    android:orientation="horizontal"
    android:padding="5dip" >

<TextView
    android:id="@+id/txtTotalAmount"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView1"
    android:layout_below="@+id/textView1"
    android:textColor="#a60704"
    android:text="TextView" />

<TextView
    android:id="@+id/txtItemDetails"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView3"
    android:layout_below="@+id/textView3"
    android:textColor="#a60704"
    android:text="Item Details Here" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/txtTotalAmount"
    android:layout_below="@+id/txtTotalAmount"
    android:layout_marginTop="17dp"
    android:text="Ordered Items:"
    android:textColor="#a60704"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text="Total Amount"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="#a60704" />

</RelativeLayout>


您的适配器说它没有任何项,因为getCount()在OrdersAdapter.java类中返回0

问题 您必须以适当的方式重写适配器getCount()方法,如

 public int getCount() {
        return SIZE_OF_ARRAYLIST;

    }

如果写入返回0,则不会显示列表。所以您需要返回arrayList的大小,并传递一个集合,比如构造函数中的字符串

public OrdersAdapter(Activity a, List stringsToShow) {
    // TODO Auto-generated constructor stub
    activity = a;
    inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   this.stringsToShow = stringsToShow;
}
然后

public int getCount() {
    return stringsToShow.size();

}

并避免在getView()中执行太多操作。。Kamal karte ho Pande ji.

如果在
活动中解析
json
而不是
BaseAdapter
getView()
将被多次调用,因此json将被多次解析