android仿美团评论

1.仿美团评论布局,效果图,其中引用了

compile 'com.github.ome450901:SimpleRatingBar:1.3.5'

android仿美团评论_第1张图片

2.listview_pingjia_item.xml



    

        

            

            
                
                
                
            

            
        

        
    
3.activity_pingjia.xml



    


        
    
    


4.Myadapter
 
  
package com.example.mama.testdemo;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

/**
 * Created by dingkangkang on 2017/12/1.
 */

public class Myadapter extends BaseAdapter{
    Context context;
    public Myadapter(Context contexts){
        context=contexts;
    }
    @Override
    public int getCount() {
        return 30;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = LayoutInflater.from(context).inflate(R.layout.listview_pingjia_item,null);
        return convertView;
    }

}


 
  
 
  

 
  
 
  
5.MainActivity

package com.example.mama.testdemo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;

public class MainActivity extends AppCompatActivity {

    private ListView lv_dongtai;
    private Myadapter myadapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pingjia);

        lv_dongtai = (ListView) findViewById(R.id.lv_dongtai);
        myadapter = new Myadapter(this);
        lv_dongtai.setAdapter(myadapter);
    }
}

源码


 
  
 
 

你可能感兴趣的:(Android布局)