我從Flickr獲取圖像並在gridview中顯示它們。 問題是textview顯示在gridview的頂部。
我做了什麼至今:
mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> gridView, View view, int pos,
long id) {
GalleryItem item = mItems.get(pos);
LinearLayout layout = new LinearLayout(getContext());
layout.setLayoutParams(new GridView.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
layout.setOrientation(LinearLayout.HORIZONTAL);
TextView textview = new TextView(getContext());
textview.setLayoutParams(new LinearLayout.LayoutParams(
android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
textview.setText("Get the Position " + pos);
textview.setTextColor(Color.RED);
layout.addView(textview);
}
});
這是我想要的。這就是我所做的。好。現在,您發佈的代碼有什麼問題? – csmckelvey
你到底想要做什麼? –
正如你在圖像中看到的,當單擊網格視圖中的任何單元格時都會顯示文本視圖。我只是想實現這種UI。我嘗試動態添加文本視圖,但它顯示在頂部網格視圖。@ LuizFernandoSalvaterra – wonderPub