Hi,
I have used mostly the same way of showing multiple listviews as you
suggested i.e. using setvisibility.
But now what I want is to have the Bitmap image of all the four
listviews. Suppose, my activity starts and the data are loaded into
all the four listviews by binding them to their respective adapters.
Now, when I am trying to fetch the Bitmap using getDrawingCache() it
always returns null to me.
So, can you let me know how can I fetch the Bitmap of all the four
listviews?
public class HomeScreenActivity extends Activity
{
private ImageView imgBabble = null;
private ListView listBabble = null;
private ListView listVille = null;
private ListView listPrivateMsgs = null;
private ListView listBookmarks = null;
private List<String> tempBabble = null;
private List<String> tempVille = null;
private List<String> tempPrivateMsgs = null;
private List<String> tempBookmarks = null;
//RelativeLayouts
private RelativeLayout babbleLayout = null;
private RelativeLayout villeLayout = null;
private RelativeLayout privateMsgsLayout = null;
private RelativeLayout bookmarksLayout = null;
//Bitmap
private Bitmap babbleShrunkView = null;
private Bitmap villeShrunkView = null;
private Bitmap privateMsgsShrunkView = null;
private Bitmap bookmarksShrunkView = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.homescreen);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
R.layout.customtitle);
imgBabble = (ImageView) findViewById(R.id.imgBtnBabble);
Bitmap bitmapOrg =
BitmapFactory.decodeResource(getResources(),R.drawable.babble_top_logo);
BitmapDrawable bmpDrawable = new BitmapDrawable(bitmapOrg);
imgBabble.setBackgroundDrawable(bmpDrawable);
//Initialize the layouts for Babble, Ville, Private Messages
and Bookmarks
babbleLayout = (RelativeLayout)
findViewById(R.id.babbleLayout);
babbleLayout.setDrawingCacheEnabled(true);
villeLayout = (RelativeLayout) findViewById(R.id.villeLayout);
villeLayout.setDrawingCacheEnabled(true);
privateMsgsLayout = (RelativeLayout)
findViewById(R.id.privatemsgsLayout);
privateMsgsLayout.setDrawingCacheEnabled(true);
bookmarksLayout = (RelativeLayout)
findViewById(R.id.bookmarksLayout);
bookmarksLayout.setDrawingCacheEnabled(true);
//Babble
tempBabble = new ArrayList<String>();
tempBabble.add("First Babble");
tempBabble.add("Second Babble");
tempBabble.add("Third Babble");
listBabble = (ListView) findViewById(R.id.listBabble);
listBabble.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_multiple_choice, tempBabble));
// babbleShrunkView = babbleLayout.getDrawingCache();
//babbleLayout = (RelativeLayout)
findViewById(R.id.listLayout);
if(babbleShrunkView == null)
{
System.out.println("Babble View is null");
}
//Ville
tempVille = new ArrayList<String>();
tempVille.add("First Ville");
tempVille.add("Second Ville");
tempVille.add("Third Ville");
listVille = (ListView) findViewById(R.id.listVille);
//listVille.setDrawingCacheEnabled(true);
listVille.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_multiple_choice, tempVille));
//villeShrunkView = villeLayout.getDrawingCache();
if(villeShrunkView == null)
{
System.out.println("Ville View is null");
}
//listVille.setVisibility(View.GONE);
//Private Messages
tempPrivateMsgs = new ArrayList<String>();
tempPrivateMsgs.add("First PM");
tempPrivateMsgs.add("Second PM");
tempPrivateMsgs.add("Third PM");
listPrivateMsgs = (ListView)
findViewById(R.id.listPrivateMessages);
//listPrivateMsgs.setDrawingCacheEnabled(true);
listPrivateMsgs.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_multiple_choice, tempPrivateMsgs));
//privateMsgsShrunkView = privateMsgsLayout.getDrawingCache();
if(privateMsgsShrunkView == null)
{
System.out.println("Private Messages View is null");
}
//listPrivateMsgs.setVisibility(View.GONE);
//Bookmarks
tempBookmarks = new ArrayList<String>();
tempBookmarks.add("First Bookmarks");
tempBookmarks.add("Second Bookmarks");
tempBookmarks.add("Third Bookmarks");
listBookmarks = (ListView) findViewById(R.id.listBookmarks);
//listBookmarks.setDrawingCacheEnabled(true);
listBookmarks.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_multiple_choice, tempBookmarks));
//bookmarksShrunkView = bookmarksLayout.getDrawingCache();
if(bookmarksShrunkView == null)
{
System.out.println("Bookmarks Messages View is null");
}
//listBookmarks.setVisibility(View.GONE);
imgBabble.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
System.out.println("Babble Clicked");
babbleShrunkView =
babbleLayout.getDrawingCache();
villeShrunkView = villeLayout.getDrawingCache();
privateMsgsShrunkView =
privateMsgsLayout.getDrawingCache();
bookmarksShrunkView =
bookmarksLayout.getDrawingCache();
BabbleVilleShrinkView.addBitmap(0,
resizeBitmap(200, 200,
babbleShrunkView));
BabbleVilleShrinkView.addBitmap(1,
resizeBitmap(200, 200,
villeShrunkView));
BabbleVilleShrinkView.addBitmap(2,
resizeBitmap(200, 200,
privateMsgsShrunkView));
BabbleVilleShrinkView.addBitmap(3,
resizeBitmap(200, 200,
bookmarksShrunkView));
Gallery gallery = new
Gallery(getApplicationContext());
gallery.setAdapter(new
ImageAdapter(getApplicationContext()));
}
});
}
I am trying to fetch the Bitmap of those listviews and then load it in
the Gallery. Can someone point out the reason behind getDrawingCache
returning null all time.
Thanks & Regards
Sunil
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
To unsubscribe, reply using "remove me" as the subject.