Xem chi tiết tại :
http://www.quan9.hochiminhcity.gov.vn/Hnh%20nh%20bn%20tin/QHC%20Q9_final.png
Điều kiện tách thửa đất : http://thuvienphapluat.vn/van-ban/Bat-dong-san/Quyet-dinh-33-2014-QD-UBND-dien-tich-toi-thieu-tach-thua-Ho-Chi-Minh-253669.aspx
public V get(Object key) {
Node<K,V> e;
return (e = getNode(hash(key), key)) == null ? null : e.value;
}
static final int hash(Object key) {
int h;
return (key == null) ? 0 : (h = key.hashCode()) ^ (h >>> 16);
}
<
?xml version="1.0" encoding="utf-8"?
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.manngo.shoppingcartsimple.MainActivity">
<TextView
android:layout_gravity="center_horizontal"
android:layout_margin="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/title_page"
android:text="CatalogProduct"
android:textSize="15dp"
/>
<ListView
android:id="@+id/list_catalog"
android:background="#ff9100"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
</ListView>
<Button
android:layout_margin="5dp"
android:text="ViewCart"
android:id="@+id/button_view_cart"
android:layout_gravity="right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
* Layout Trang DetailActivity như sau :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.manngo.shoppingcartsimple.ProductDetailActivity">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_margin="5dp"
android:layout_width="120dp"
android:layout_height="120dp"
android:id="@+id/image_product_detail"/>
<LinearLayout
android:orientation="vertical"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="match_parent">
<TextView
android:textSize="20dp"
android:textStyle="bold"
android:text="Product Title"
android:id="@+id/text_title_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:textSize="20dp"
android:textStyle="normal"
android:text="Price"
android:textColor="#ff0011"
android:id="@+id/text_price_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/edt_quantity_detail"
android:hint="Enter Quantity"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
<TextView
android:layout_margin="5dp"
android:background="#e6d7a1"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Mo ta San Pham"
android:id="@+id/text_discription_detail"/>
<Button
android:layout_gravity="right"
android:text="Add Cart"
android:id="@+id/button_add_cart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
* Layout trang giỏ hàng (CartActivity) như sau :public class ShoppingCartHelper { public static final String PRODUCT_INDEX = "PRODUCT_INDEX"; private static List<Product> listCatalog; private static List<Product> listCart; // tạo danh mục sản phẩm public static List<Product> getCatalog(Resources res){ if (listCatalog == null){ listCatalog = new Vector<Product>(); listCatalog.add(new Product("San Pham 1", res.getDrawable(R.drawable.android),"This isSan Pham 1", 31.20)); listCatalog.add(new Product("San Pham 2", res.getDrawable(R.drawable.android3),"This isSan Pham 2", 31.20)); listCatalog.add(new Product("San Pham 3", res.getDrawable(R.drawable.android5),"This isSan Pham 3", 31.20)); listCatalog.add(new Product("San Pham 4", res.getDrawable(R.drawable.glass_eyes2),"This isSan Pham 4", 31.20)); listCatalog.add(new Product("San Pham 5", res.getDrawable(R.drawable.glass_eyes3),"This isSan Pham 5", 31.20)); listCatalog.add(new Product("San Pham 6", res.getDrawable(R.drawable.hinh13),"This isSan Pham 6", 31.20)); } return listCatalog; } // tạo giỏ hàng public static List<Product> getCart(){ if (listCart == null){ listCart = new Vector<Product>(); } return listCart; } }
public class ShoppingCart2Activity extends AppCompatActivity { ListView lvCart; Button btnProceedToCheckout; private List<Product> mCartList; private CartAdapter adapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_shopping_cart2); init(); displayCart(); RemoveProductFromCart(); } private void init(){ // lvCart = (ListView) findViewById(R.id.list_cart); btnProceedToCheckout = (Button) findViewById(R.id.button_procced_to_checkout); } private void displayCart(){ mCartList = ShoppingCartHelper.getCart(); // Make sure to clear the selection
for(int i=0; i<mCartList.size(); i++) { mCartList.get(i).selected = false; } // Create the list final ListView listViewCatalog = (ListView) findViewById(R.id.list_cart); adapter = new CartAdapter(mCartList, getLayoutInflater(), true); listViewCatalog.setAdapter(adapter); listViewCatalog.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Product selectedProduct = mCartList.get(position); if(selectedProduct.selected == true) selectedProduct.selected = false; else selectedProduct.selected = true; adapter.notifyDataSetInvalidated(); } }); } private void RemoveProductFromCart(){ Button removeButton = (Button) findViewById(R.id.button_remove_from_cart); removeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Loop through and remove all the products that are selected
// Loop backwards so that the remove works correctly
for(int i=mCartList.size()-1; i>=0; i--) { if(mCartList.get(i).selected) { mCartList.remove(i); } } adapter.notifyDataSetChanged(); } }); } }