How to add Image into layout in case of ListActivity?

Put your problem here if it does not fit any of the other categories.

How to add Image into layout in case of ListActivity?

Postby zeeshan » Mon Mar 03, 2008 6:39 am

I am able to add image in the Title bar in case of Activity.

but not in case of List Activity?
How to add Image in the title bar in case of ListActivity?

I want to create a layout on which a imageview will be shown.
how can i load this layout into listactivity i have custom listactivity

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2.  
  3.      android:layout_width="wrap_content"
  4.  
  5.         android:layout_height="wrap_content">
  6.  
  7.        
  8.  
  9.  
  10.  
  11. ...ImageView...
  12.  
  13.    
  14.  
  15.  
  16.  
  17. </LinearLayout>
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


Can We do something like that by using themes please help me out ?

i am also uploading my list activity screen

on the top i want to show my company logo
Attachments
new data.PNG
new data.PNG (178.89 KiB) Viewed 2969 times
zeeshan
Experienced Developer
Experienced Developer
 
Posts: 68
Joined: Mon Mar 03, 2008 6:10 am

Top

Postby nisha » Thu Mar 06, 2008 6:29 am

Hi,

hey can u share the code for this.... is it possible if i am using m3 version sdk?
nisha
Experienced Developer
Experienced Developer
 
Posts: 80
Joined: Fri Feb 15, 2008 7:52 am

Postby zeeshan » Thu Mar 06, 2008 10:31 am

why dont you update your sdk to m5 then i can share my code please let me know
zeeshan
Experienced Developer
Experienced Developer
 
Posts: 68
Joined: Mon Mar 03, 2008 6:10 am

Postby qamerfarooq » Thu Mar 06, 2008 2:51 pm

zeeshan wrote:why dont you update your sdk to m5 then i can share my code please let me know


Zeeshan,

Would be nice if you could share your code as i am running the m5 SDK. Is your solution different from the IconifiedTextList implementation?
Qamer Farooq
End 2 End Solution Providers
http://www.e2esp.com
qamerfarooq
Junior Developer
Junior Developer
 
Posts: 13
Joined: Fri Jan 11, 2008 6:07 am
Location: Pakistan

Postby nisha » Mon Mar 10, 2008 2:23 pm

Hi,


k... i will try with m5.. can you send me the code???


Regards,
Farah :)
nisha
Experienced Developer
Experienced Developer
 
Posts: 80
Joined: Fri Feb 15, 2008 7:52 am

Here is the code nisha

Postby zeeshan » Thu Mar 13, 2008 1:19 pm

package com.gps.framework.rivepoint.ListView;

import java.util.ArrayList;
import java.util.List;

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


public class BulletedTextListAdapter extends BaseAdapter {

private Context mContext;

private List<BulletedText> mItems;

private boolean isFirst;

/**
*
* @param context
*/
public BulletedTextListAdapter(Context context) {
mContext = context;
mItems = new ArrayList<BulletedText>();

}
public void clear(Context context) {
mContext = context;
mItems = new ArrayList<BulletedText>();

}
/**
*
* @param bt
*/
public void addItem(BulletedText bt) {
mItems.add(bt);
}

/**
*
* @param bti
*/
public void setListItems(List<BulletedText> bti) {
mItems = bti;
}

/**
* The number of items in the
*/
public int getCount() {
return mItems.size();
}

/**
*
*/
public Object getItem(int position) {
return mItems.get(position);
}

/**
*
*/
public boolean areAllItemsSelectable() {
return false;
}

/**
*
*/
public boolean isSelectable(int position) {
return mItems.get(position).isSelectable();
}

/**
* Use the array index as a unique id.
*/
public long getItemId(int position) {
return position;
}

/**
* Make a BulletedTextView to hold each row.
*/
public View getView(int position, View convertView, ViewGroup parent) {
BulletedTextView btv;
if (convertView == null) {
btv = new BulletedTextView(mContext, mItems.get(position).getText(),
mItems.get(position).getBullet());
} else {
btv = (BulletedTextView) convertView;
btv.setText(mItems.get(position).getText());
btv.setBullet(mItems.get(position).getBullet());
}

return btv;
}
}




package com.gps.framework.rivepoint.ListView;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class BulletedTextView extends LinearLayout { //here i changed

private TextView mText;
private TextView mText1;
private ImageView mBullet;


public BulletedTextView(Context context) {
super(context);

}

public BulletedTextView(Context context, String text, Drawable bullet) {
super(context);


this.setOrientation(HORIZONTAL);

mBullet = new ImageView(context);
mBullet.setImageDrawable(bullet);
// left, top, right, bottom
//mBullet.setPadding(5, 0, 20, 50);

mBullet.setPadding(0, 0, 25, 0);
addView(mBullet, new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT));

mText = new TextView(context);
mText.setPadding(0, 0, 0, 10);
mText.setText(text);
addView(mText, new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT));



}

public void setText(String words) {
mText.setText(words);
}

public void setBullet(Drawable bullet) {
mBullet.setImageDrawable(bullet);
}




}




package com.gps.framework.rivepoint.ListView;

import android.graphics.drawable.Drawable;


public class BulletedText extends Object {

private String mText = "";//make it a collection to set more texts
private Drawable mBullet;
private boolean mSelectable = true;

/**
*
* @param text
* @param bullet
*/
public BulletedText(String text, Drawable bullet) {
mBullet = bullet;
mText = text;
}

/**
*
* @return
*/
public boolean isSelectable() {
return mSelectable;
}

/**
*
* @param selectable
*/
public void setSelectable(boolean selectable) {
mSelectable = selectable;
}

/**
*
* @return
*/
public String getText() {
return mText;
}

/**
*
* @param text
*/
public void setText(String text) {
mText = text;
}

/**
*
* @param bullet
*/
public void setBullet(Drawable bullet) {
mBullet = bullet;
}

/**
*
* @return
*/
public Drawable getBullet() {
return mBullet;
}
}





BulletedText bt1 = new BulletedText("GET COUPONS",getResources().getDrawable(R.drawable.icon_get_coupons));
BulletedText bt2 = new BulletedText("SEARCH POI",getResources().getDrawable(R.drawable.icon_search_coupons));
BulletedText bt3 = new BulletedText("SAVED COUPON",getResources().getDrawable(R.drawable.icon_save_coupons));
BulletedText bt4 = new BulletedText("MANAGE COUPON",getResources().getDrawable(R.drawable.icon_manage_coupons));
BulletedText bt5 = new BulletedText("SETTINGS",getResources().getDrawable(R.drawable.icon_settings_coupons));
btla.addItem(bt1);
btla.addItem(bt2);
btla.addItem(bt3);
btla.addItem(bt4);
btla.addItem(bt5);
setListAdapter(btla);
zeeshan
Experienced Developer
Experienced Developer
 
Posts: 68
Joined: Mon Mar 03, 2008 6:10 am

Top

Postby nk » Fri Mar 14, 2008 4:08 pm

Thanks for the Code, can use it too.
nk
Junior Developer
Junior Developer
 
Posts: 21
Joined: Tue Jan 29, 2008 3:23 pm

Postby nisha » Mon Mar 31, 2008 6:45 am

Hi ,


Thanks i got it....


Regards,
nisha
nisha
Experienced Developer
Experienced Developer
 
Posts: 80
Joined: Fri Feb 15, 2008 7:52 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot], MSNbot Media and 21 guests