私の MainActivity はアクティビティを拡張getContext()
し、MainActivity のインスタンスが渡された別のクラスで使用し、そこで正常に動作します、私のコード:
convertView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.nowview, parent, false);
クラス コンストラクター:
public PictureCard(String url, String title, int index,
int pos, MainActivity parent)
{
this.parent = parent;
// ...
}
クラスの呼び方
Card newCard = new PictureCard(links.get(index) , titles.get(index),
index, position, parent);
(親は MainActivity クラスから this として渡されます)