예제 #1
0
  private void showAdDetails(long id) {

    DatabaseOpenHelper db = new DatabaseOpenHelper(getApplicationContext());

    AdDetailsModel ad = db.getAd(id);

    String title = ad.getTitle();
    String category = ad.getCategory();
    String description = ad.getDescription();
    String name = ad.getName();
    String location = ad.getLocation();
    String phone = ad.getPhone();
    // (long)String ph = String.valueOf(phone);
    int price = ad.getPrice();
    byte[] image = ad.getImage();
    Bitmap photo = BitmapFactory.decodeByteArray(image, 0, image.length);
    if (photo == null) {
      Log.v(LOG_TAG, "byte image unable to decode...");
    }

    TextView displayTitle = (TextView) findViewById(R.id.title_textView);
    displayTitle.setText(title);
    TextView displayCategory = (TextView) findViewById(R.id.category_textView);
    displayCategory.setText(category);
    TextView displayDescription = (TextView) findViewById(R.id.textView_description);
    displayDescription.setText(description);
    TextView displayName = (TextView) findViewById(R.id.name_textView);
    displayName.setText(name);
    TextView displayLocation = (TextView) findViewById(R.id.textView_location);
    displayLocation.setText(location);
    TextView displayPhone = (TextView) findViewById(R.id.textView_phone);
    displayPhone.setText(phone);
    TextView displayPrice = (TextView) findViewById(R.id.textView_price2);
    displayPrice.setText(Integer.toString(price));
    ImageView displayImage = (ImageView) findViewById(R.id.showImage_View);
    displayImage.setImageBitmap(photo);
  }
예제 #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_show_ad);

    Intent intent = getIntent();
    db = new DatabaseOpenHelper(getApplicationContext());
    // set the default value for the intent using getCount()
    // Log.v(LOG_TAG, "row count = "+ db.getRowCount());
    long id = intent.getLongExtra("EXTRA_TEXT", db.getRowCount());

    // Log.v(LOG_TAG, "row id = "+ id);
    showAdDetails(id);

    Button back = (Button) findViewById(R.id.back_button);
    back.setOnClickListener(this);
  }