我正在嘗試開發我的第一款遊戲,但我遇到了麻煩,這是我很困惑的事情。基本上我需要加載2個我在Photoshop中創建的圖像,但是如果點擊它們,同一形狀的不同圖像將被繪製在頂部,使其看起來像被選中,然後如果有人點擊其他圖像,回到初始狀態,第二個圖像放在最上面...我怎樣才能做到這一點?Android更改圖片
我只是有關於如何將初始圖像加載到屏幕上thenbe能夠與其他人交換他們的麻煩...
謝謝
我正在嘗試開發我的第一款遊戲,但我遇到了麻煩,這是我很困惑的事情。基本上我需要加載2個我在Photoshop中創建的圖像,但是如果點擊它們,同一形狀的不同圖像將被繪製在頂部,使其看起來像被選中,然後如果有人點擊其他圖像,回到初始狀態,第二個圖像放在最上面...我怎樣才能做到這一點?Android更改圖片
我只是有關於如何將初始圖像加載到屏幕上thenbe能夠與其他人交換他們的麻煩...
謝謝
如果我明白你的問題的權利,這聽起來像使用標籤將是一個解決方案。 水木清華像這可能是第一步,你的遊戲
public class MyTab extends TabActivity{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tabs);
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The acWednesdaytivity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, YourWithImage1.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("tab1").setIndicator("tab1",
res.getDrawable(R.drawable.ic_tab))
.setContent(intent);
tabHost.addTab(spec);
}}
和你ic_tab看起來就像
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- When selected, use grey img-->
<item android:drawable="@drawable/ic_tab_grey"
android:state_selected="true" />
<!-- When not selected, use white img-->
<item android:drawable="@drawable/ic_tab_white" />
</selector>
我是新自己的Andorid。希望這會有所幫助。
我也是Android新手,所以不確定我是否有正確的答案。但這裏是我可能會嘗試:
同樣,我也是Android的新手,所以我不是從經驗談話。我希望這有幫助。
請參見下面的鏈接,我正好橫跨來: http://www.higherpass.com/Android/Tutorials/Working-With-Images-In-Android/