בעיה עם addview ל layout אנדרואיד

terra2

New member
בעיה עם addview ל layout אנדרואיד

ניסיתי לעשות את הדבר הבא

LayoutInflater inflater2 = (LayoutInflater) getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

ViewGroup fr=(ViewGroup) inflater2.inflate(R.layout.activity_main,null);
ViewGroup a=(ViewGroup)fr.findViewById(R.id.dashboard);
a.addView(im,50,50);


וכמובן לא התווסף ל layout שבחרתי את ה imageview שצירפתי.
אני חייב למצוא דרך לקשר בין ה context ל viewgroup כדי להוסיף אובייקטים למסך לתוך layout.
יש רעיונות?

בלי ה inflater ו ה context זה עובד .. אבל בתנאי שאני באותה מחלקה.

תודה.
 
למעלה