-2
類更改視圖
linearlayout
但不起作用此代碼
main.java
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ComNet.readDb();
}
}
和:
ComNet.java
public class ComNet {
public static Context context;
public static void readDb() {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View viewMain = inflater.inflate(R.layout.main, null);
LinearLayout lnrPart = (LinearLayout) viewMain.findViewById(R.id.lnrPart);
lnrPart.setVisibility(View.GONE);
}
}
如何從main.xml
類(ComNet
)改變lnrPart
?
謝謝,但此行錯誤:android.R.layout.main,錯誤:主要解決不了或無法在現場 – Mohammad
修正了代碼...只是抹去android。在R.layout.main之前 – ilan