zahra.mf
جمعه 19 تیر 1394, 18:25 عصر
سلام داخل برنامه من یه صفحه xml هست که توی چندتا گوشی امتحان کردم مشکل نداشته ولی روی نوت3 و نوت 4 بالا نمیاد توی کد جاوای اون صحه این و نوشتم
public class haj_main extends Activity{
private Button btnAhamiat,btnAhkam,btnAmaken;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.haj_main);
btnAhamiat =(Button) findViewById(R.id.image_ahamiat_haj);
btnAhkam =(Button) findViewById(R.id.image_ahkam_haj);
btnAmaken =(Button) findViewById(R.id.image_amaken);
btnAhamiat.setOnClickListener(new OnClickListener(){
public void onClick(View arg0) {
btnAhamiat.setFocusableInTouchMode(false);
btnAhamiat.setFocusable(false);
Intent i=new Intent(haj_main.this,list_ahamiat.class);
startActivity(i);
}
});
btnAhkam.setOnClickListener(new OnClickListener(){
public void onClick(View arg0) {
btnAhkam.setFocusableInTouchMode(false);
btnAhkam.setFocusable(false);
Intent i=new Intent(haj_main.this,ahkam.class);
startActivity(i);
}
});
btnAmaken.setOnClickListener(new OnClickListener(){
public void onClick(View arg0) {
btnAmaken.setFocusableInTouchMode(false);
btnAmaken.setFocusable(false);
Intent i=new Intent(haj_main.this,amaken.class);
startActivity(i);
}
});
setsize();
}
private void setsize(){
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics( dm);
int h=dm.heightPixels;
int w=dm.widthPixels;
h=h/4;
w=w-((w*20)/100);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(w, h);
btnAhamiat.setLayoutParams(params);
btnAhkam.setLayoutParams(params);
btnAmaken.setLayoutParams(params);
}
}
کد xml هم این هست
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_horizontal"
android:background="@drawable/back">
<Button
android:id="@+id/image_ahamiat_haj"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/selector_ahamiat" />
<Button
android:id="@+id/image_ahkam_haj"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/selector_ahkam" />
<Button
android:id="@+id/image_amaken"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/selector_amaken" />
</LinearLayout>
کسی میتونه کمک کنه؟
public class haj_main extends Activity{
private Button btnAhamiat,btnAhkam,btnAmaken;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.haj_main);
btnAhamiat =(Button) findViewById(R.id.image_ahamiat_haj);
btnAhkam =(Button) findViewById(R.id.image_ahkam_haj);
btnAmaken =(Button) findViewById(R.id.image_amaken);
btnAhamiat.setOnClickListener(new OnClickListener(){
public void onClick(View arg0) {
btnAhamiat.setFocusableInTouchMode(false);
btnAhamiat.setFocusable(false);
Intent i=new Intent(haj_main.this,list_ahamiat.class);
startActivity(i);
}
});
btnAhkam.setOnClickListener(new OnClickListener(){
public void onClick(View arg0) {
btnAhkam.setFocusableInTouchMode(false);
btnAhkam.setFocusable(false);
Intent i=new Intent(haj_main.this,ahkam.class);
startActivity(i);
}
});
btnAmaken.setOnClickListener(new OnClickListener(){
public void onClick(View arg0) {
btnAmaken.setFocusableInTouchMode(false);
btnAmaken.setFocusable(false);
Intent i=new Intent(haj_main.this,amaken.class);
startActivity(i);
}
});
setsize();
}
private void setsize(){
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics( dm);
int h=dm.heightPixels;
int w=dm.widthPixels;
h=h/4;
w=w-((w*20)/100);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(w, h);
btnAhamiat.setLayoutParams(params);
btnAhkam.setLayoutParams(params);
btnAmaken.setLayoutParams(params);
}
}
کد xml هم این هست
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_horizontal"
android:background="@drawable/back">
<Button
android:id="@+id/image_ahamiat_haj"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/selector_ahamiat" />
<Button
android:id="@+id/image_ahkam_haj"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/selector_ahkam" />
<Button
android:id="@+id/image_amaken"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/selector_amaken" />
</LinearLayout>
کسی میتونه کمک کنه؟