Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid make activity with tabs and dynamically add views in each fragment
    primarykey
    data
    text
    <p>I am trying to make an activity have swipable tabs, with each tab having a different fragment (I dont know yet how many fragments I am going to have, so assume they will be at least 5). So I am having problems make the parent activity with the tabs (if I said that correctly) and then the fragments themselves have some dynamically added views (text views and one image view) which get their stuff from different async tasks, executed when the fragment is showed. Don't know if I explained it correctly, but here is my code and I'll ask you please to add in it the needed stuff.</p> <p>So here is the parrent activity which must host the tabs and the fragments:</p> <pre><code>public class SecondActivity extends FragmentActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_second); } } </code></pre> <p>and here is one of the fragments (the others are similar):</p> <pre><code>public class Fragment1 extends Fragment { LinearLayout layout; ImageView iv; String anotherURL; ArrayList&lt;InfoStuff&gt; ci; public Fragment1() { // Empty constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment1, container, false); layout = (LinearLayout) rootView.findViewById(R.id.layout); iv = (ImageView) rootView.findViewById(R.id.ivPortrait); Bundle b = this.getArguments(); ci = b.getParcelableArrayList("infoStuff"); regionUrl = b.getString("someURL"); createViews(); return rootView; } public void createViews() { TextView tv; tv = new TextView(v.getContext()); tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tv.setText("le text"); layout.addView(tv); tv = new TextView(v.getContext()); tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tv.setText("some text"); layout.addView(tv); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(v.getApplicationContext()).build(); ImageLoader.getInstance().init(config); String imgUrl = "someURL"; ImageLoader.getInstance().displayImage(imgUrl, iv); } } </code></pre> <p>I am also having troubles making the ImageView work, as it is from an additional library (forgot the name, heres the import though import com.nostra13.universalimageloader.core.ImageLoader;)</p> <p>EDIT: Sorry, forgot to mention the tabs must be swipeable</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload