pvhoaivh4394 / demo

0 stars 0 forks source link

Kim so hyun #1

Open pvhoaivh4394 opened 7 years ago

pvhoaivh4394 commented 7 years ago

@ photo676896 20160921_kimsohyun3 1473689429621_600

pvhoaivh4394 commented 7 years ago

1473689429621_600

pvhoaivh4394 commented 7 years ago

kimsohyun.zip

pvhoaivh4394 commented 7 years ago

package com.example.hcd_fresher043.sample;

import android.content.Intent; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.ListView;

import java.util.ArrayList;

/**

public class ListViewActivity extends AppCompatActivity implements AdapterItemList.myOnClick{ private ArrayList versions; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.list_view); ListView ls= (ListView) findViewById(R.id.list); versions=new ArrayList<>(); for(int i=0;i<50;i++){ versions.add(new Version("Title "+i,"Version "+i)); }

    AdapterItemList adapterItemList=new AdapterItemList(this,versions);
    adapterItemList.setMyOnClick(this);
   /* ls.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

        }
    });*/
    ls.setAdapter(adapterItemList);
}

@Override
public void onClick(int position) {
    Log.d("ListActivity","click:"+position);
    Intent i=new Intent(this,ShowInformation.class);
    i.putExtra("Version",versions.get(position));
    startActivity(i);
}

}

pvhoaivh4394 commented 7 years ago

package com.example.hcd_fresher043.sample;

import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.widget.TextView;

/**

public class ShowInformation extends AppCompatActivity{ @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.show); TextView txtTitle= (TextView) findViewById(R.id.title); TextView txtVersion= (TextView) findViewById(R.id.Version); Version v= (Version) getIntent().getSerializableExtra("Version"); txtTitle.setText(v.getTitle()); txtVersion.setText(v.getVersion()); } }

pvhoaivh4394 commented 7 years ago

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:layout_width="match_parent" android:id="@+id/title" android:textSize="24sp" android:layout_height="wrap_content" /> <TextView android:layout_width="match_parent" android:id="@+id/Version" android:textSize="20sp" android:layout_height="wrap_content" />

pvhoaivh4394 commented 7 years ago

package com.example.hcd_fresher043.sample;

import java.io.Serializable;

/**

public class Version implements Serializable {

private String imagePath;

private String title;

private String version;

public String getImagePath() {
    return imagePath;
}

public void setImagePath(String imagePath) {
    this.imagePath = imagePath;
}

public String getTitle() {
    return title;
}

public void setTitle(String title) {
    this.title = title;
}

public String getVersion() {
    return version;
}

public void setVersion(String version) {
    this.version = version;
}

public Version(String title, String version) {
    this.title = title;
    this.version = version;
}

}

pvhoaivh4394 commented 7 years ago

package com.example.hcd_fresher043.sample;

import android.content.Context; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.TextView;

import java.util.ArrayList;

/**

public class AdapterItemList extends BaseAdapter { private ArrayList data; private Context context; myOnClick myOnClick;

public void setMyOnClick(AdapterItemList.myOnClick myOnClick) {
    this.myOnClick = myOnClick;
}

public AdapterItemList(Context context, ArrayList<Version> data){
    this.data=data;
    this.context=context;
}
@Override
public int getCount() {
    return 1;

}

@Override
public Version getItem(int i) {
    return data.get(i);
}

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

@Override
public View getView(final int i, View convertview, ViewGroup viewGroup) {
    viewHolder chido;
    if(convertview==null)
    {
        convertview=LayoutInflater.from(context).inflate(R.layout.item_list_view,viewGroup,false);
        chido=new viewHolder();
        chido.img= (ImageView) convertview.findViewById(R.id.icon);
        chido.title= (TextView) convertview.findViewById(R.id.title);
        chido.Version= (TextView) convertview.findViewById(R.id.version);
        chido.btnnext=(ImageButton) convertview.findViewById(R.id.row);
        convertview.setTag(chido);
    }else{
        chido= (viewHolder) convertview.getTag();
    }

    Version version=getItem(i);
    chido.title.setText(version.getTitle());
    chido.Version.setText(version.getVersion());
    chido.btnnext.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            myOnClick.onClick(i);
        }
    });
    return convertview;
}
class viewHolder{
    ImageView img;
    TextView title;
    TextView Version;
    ImageButton btnnext;
}
interface myOnClick{
    void onClick(int position);
}

}

pvhoaivh4394 commented 7 years ago

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:layout_width="wrap_content" android:id="@+id/icon" android:padding="@dimen/activity_vertical_margin" android:background="@drawable/ic_android_black_24dp" android:layout_height="wrap_content" /> <LinearLayout android:layout_width="wrap_content" android:orientation="vertical" android:layout_toRightOf="@+id/icon" android:layout_alignTop="@+id/icon" android:gravity="center_vertical" android:layout_alignBottom="@+id/icon" android:layout_height="wrap_content"

<TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000000" android:textSize="20sp" android:textStyle="bold" android:text="ccc"/> <TextView android:id="@+id/version" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000000" android:textStyle="italic" android:textSize="18sp" android:text="nhan cho thoi"/> <ImageButton android:layout_alignParentRight="true" android:layout_centerVertical="true" android:layout_width="wrap_content" android:id="@+id/row" android:src="@android:drawable/ic_media_next" android:layout_height="wrap_content" />