layContent = (LinearLayout) findViewById(R.id.ll_survey_list);
TextView textQuestion;
textQuestion = new TextView(this);
textQuestion.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
textQuestion.setTextColor(Color.parseColor("#000000"));
textQuestion.setPadding(8,35,3,0);
textQuestion.setVisibility(View.VISIBLE);
textQuestion.setText(surveyS.get(s));
layContent.addView(textQuestion);
我已经以编程方式创建了一个textview,我想以编程方式为像Textview这样的片段谷歌地图制作一个。我怎么能这样做?
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_centerHorizontal="true"
android:visibility="gone"/>
我的问题是这个Googlemap会在layContent
中排列答案 0 :(得分:0)
FragmentManager fragmentManager = getFragmentManager ();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction ();
fragmentTransaction.add (R.id.myFrame, myFrag);
fragmentTransaction.commit ();
点击此链接:https://www.intertech.com/Blog/programmatically-working-with-android-fragments/