2

我可以在Nutiteq中爲我的ViewLabel填充視圖,但我無法在此佈局的文本視圖中設置正確的文本。Nutiteq下的My ViewLabel無法正常工作

我的代碼如下

//Setting Popup Label if we click the area 
    LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);  
    View labelView = inflater.inflate(R.layout.popup_field, null); 

    //In order to get a dynamic "redimensionable" Ballon aka ViewLabel 
    labelView.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), 
         MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); 
    labelView.layout(0, 0, labelView.getMeasuredWidth(), labelView.getMeasuredHeight()); 

    //labelView.measure(400, 400); 
    //labelView.layout(100, 100, 400, 400); 

    Log.info("drawField:: Nach Label fieldLabel = new ViewLabel... "); 

    LinearLayout lLayout = (LinearLayout)labelView.findViewById(R.id.layout1); 
    lLayout.setBackgroundColor(Color.RED); 
    TextView farmNameTV = (TextView)labelView.findViewById(R.id.farmName); 
    TextView areaTV  = (TextView)labelView.findViewById(R.id.area); 
    TextView statusTV = (TextView)labelView.findViewById(R.id.status); 

    farmNameTV.setTextColor(Color.BLACK); 
    farmNameTV.setText("Farm CacoCaCoca"); 


    areaTV.setTextColor(Color.BLACK); 
    String areaString = "12.34" 
    areaTV.setText("Area "+areaString); 

    statusTV.setTextColor(Color.BLACK); 
    String statusString = "Status:::qwertzuiopasdfghjklyxcvbnm"; 
    statusTV.setText(statusString); 

*什麼你可以看到紅色是我的充氣查看。

enter image description here

R.layout.popup_field看起來像這樣

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/layout1" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" > 

<TextView 
    android:id="@+id/farmName" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/farmName"/> 

<TextView 
    android:id="@+id/area" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"  
    android:text="@string/area"/> 

<TextView 
    android:id="@+id/status" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"  
    android:text="@string/status"/>  

如果字符串

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
<string name="app_name">Nutiteq3D</string> 
<string name="area">Area</string> 
<string name="status">Status</string> 
<string name="farmName">Farm Name</string> 
</resources> 

有沒有人這樣做任務了嗎?任何人都可以幫我找出我的錯誤嗎?使用Google Api的MapView很容易,但是我使用Nutiteq和純活動開發了這個功能,因此,無片段和膨脹我們通常需要ViewGroup,並且此G-Api下的ViewGroup將是MapView,因此它繼承自ViewGroup,但在Nutiteq不是這樣的,Nutiteq的MapView繼承了android.view並且我無法投射,我可以在inflate的調用中將其指定爲ViewGroup null,如您所見。

所以,人們,我會非常感謝您的幫助。

親切的問候

回答

2

解決了! 它不需要做ViewLabel,但正常的Android.View,我想分配文本到TextView的後我宣佈我的可調整大小View,因此它不能正常工作。

所以將溶液寫入所有的tv.setText上述 labelView.measure(MeasureSpec.makeMeasureSpec(0,MeasureSpec.UNSPECIFIED) MeasureSpec.makeMeasureSpec(0,MeasureSpec.UNSPECIFIED)); labelView.layout(0,0,labelView.getMeasuredWidth(),labelView.getMeasuredHeight());