У меня есть эти объявления для 4 ImageButtons на моем Android приложение, но до сих пор они не являются интерактивными, это мой класс:ImageButton не кликабельна - AndroidStudio
public class WelcomeScreen extends Activity {
ImageButton completeprofile;
ImageButton gotoportfolio;
ImageButton findfriends;
ImageButton readnews;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.welcome_activity);
completeprofile = (ImageButton) findViewById(R.id.completeprofile);
gotoportfolio = (ImageButton) findViewById(R.id.gotoportfolio);
findfriends = (ImageButton) findViewById(R.id.findfriends);
readnews = (ImageButton) findViewById(R.id.readnews);
completeprofile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent i = new Intent(WelcomeScreen.this, ProfileMember.class);
startActivity(i);
}
});
gotoportfolio.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent i = new Intent(WelcomeScreen.this, PortfolioMember.class);
startActivity(i);
}
});
findfriends.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent i = new Intent(WelcomeScreen.this, MainActivity.class);
startActivity(i);
}
});
readnews.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent i = new Intent(WelcomeScreen.this, WebActivity.class);
startActivity(i);
}
});
} }
Это мой макет:
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="70dp"
android:layout_marginLeft="105dp">
<ImageButton
android:layout_width="55dp"
android:layout_height="55dp"
android:id="@+id/completeprofile"
android:background="@drawable/completeprofile"
android:layout_marginLeft="75dp"
android:clickable="true" />
<ImageButton
android:layout_width="55dp"
android:layout_height="55dp"
android:id="@+id/gotoportfolio"
android:background="@drawable/gotoportfolio"
android:layout_marginLeft="65dp"
android:clickable="true" />
<ImageButton
android:layout_width="55dp"
android:layout_height="55dp"
android:id="@+id/findfriends"
android:background="@drawable/findfriends"
android:layout_marginLeft="65dp"
android:clickable="true" />
<ImageButton
android:layout_width="55dp"
android:layout_height="55dp"
android:id="@+id/readnews"
android:background="@drawable/readnews"
android:layout_marginLeft="65dp"
android:clickable="true" />
</LinearLayout>
Они показывают, отлично, но до сих пор я не могу нажать любую из них, никакой ошибки StackTrace, я совершенно озадачен об этом =/
Никто не может пролить некоторый свет на это?
Заранее благодарен!
Перейти Построить> Очистка проекта и повторите попытку. –
Работают ли обычные кнопки? –
Да, я не очистил проект, так как я добавил его, позвольте мне попробовать то, что предлагает @GiruBhai – NeoVe