نمایش نتایج 1 تا 7 از 7

نام تاپیک: مشکل در رفتن از اکتیویتی اول به اکتیویتی دوم به استفاده از باتن در اندروید استودیو

  1. #1

    مشکل در رفتن از اکتیویتی اول به اکتیویتی دوم به استفاده از باتن در اندروید استودیو

    سلام دوستان.
    من در اندروید استودیو می خوام از اکتیویتی اولی با استفاده از باتن به اکتیویتی دومی برم، کد رو نوشتم ولی موقع اجرا مشکل داره.
    تازه کارم. راهنمایی کنید.
    در این برنامه قرار بود بوسیله باتن BtnVorood از اکتیویتی content_main.xml به اکتیویتی activity2.xml برود!!!!!
    داخل اینترنت هم چند روزه که گشتم ولی به جوابی نرسیدم.



    کدهای مربوط به activity_main.xml :
    <?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" android:fitsSystemWindows="true"
    tools:context=".MainActivity">

    <android.support.design.widget.AppBarLayout android:layout_height="wrap_content"
    android:layout_width="match_parent" android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar android:id="@+id/toolbar"
    android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_main" />

    <android.support.design.widget.FloatingActionButton android:id="@+id/fab"
    android:layout_width="wrap_content" android:layout_height="wrap_content"
    android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin"
    android:src="@android:drawable/ic_dialog_email" />

    </android.support.design.widget.CoordinatorLayout>

    ************************************************** ****************************************
    کدهای مربوط به content_main.xml

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:showIn="@layout/activity_main" tools:context=".MainActivity">


    <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="ورود"
    android:id="@+id/BtnVorood"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:clickable="true" />

    </RelativeLayout>************************************************* *****************************************
    کدهای مربوط به activity2.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="1">
    <TextView
    android:id="@+id/txt"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="اکتیویتی دوم"
    android:textSize="25dp"
    android:layout_weight="0.13"
    android:textAlignment="center"
    android:textColor="#e12727"
    android:theme="@android:style/Animation" />

    </LinearLayout>************************************************* *****************************************
    کدهای مربوط به MainActivity.java

    package com.mabdollahi.riazysara;

    import android.os.Bundle;
    import android.view.View;
    import android.app.Activity;
    import android.content.Intent;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    }
    }************************************************* *****************************************
    کدهای مربوط به ContentActivity.java

    package com.mabdollahi.riazysara;

    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.content.Intent;
    import android.widget.Button;
    import android.view.View.OnClickListener;

    public class ContentActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.content_main);
    OnClickListener listnr=new OnClickListener() {
    @Override
    public void onClick(View v) {
    Intent i= new Intent("Activity2");
    startActivity(i);
    }
    };
    Button btn =(Button) findViewById(R.id.BtnVorood);
    btn.setOnClickListener(listnr);
    }
    }
    ************************************************** ****************************************
    کدهای مربوط به Activity2.java

    package com.mabdollahi.riazysara;

    import android.app.Activity;
    import android.os.Bundle;

    public class Activity2 extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity2);
    }
    }************************************************* *****************************************
    کدهای مربوط به AndroidManifest.xml


    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mabdollahi.riazysara" >

    <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme" >
    <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:theme="@style/AppTheme.NoActionBar" >
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />

    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>
    <activity
    android:name=".Activity2"
    android:label="@string/app_name">
    <intent-filter >
    <action android:name="in.wptrafficanalyzer.MAIN"/>
    <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
    </activity>

    <activity
    android:name=".ContentActivity"
    android:label="@string/app_name">
    <intent-filter >
    <action android:name="in.wptrafficanalyzer.MAIN"/>
    <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
    </activity>
    </application>

    </manifest>
    ************************************************** ******************************************
    آخرین ویرایش به وسیله m.abdollahi : شنبه 07 فروردین 1395 در 09:14 صبح

  2. #2

    نقل قول: مشکل در رفتن از اکتیویتی اول به اکتیویتی دوم به استفاده از باتن در اندروید استودیو

    دوستان خواهش می کنم یکی جوابم رو بده. کجای کد رو اشتباه نوشتم؟

  3. #3

    نقل قول: مشکل در رفتن از اکتیویتی اول به اکتیویتی دوم به استفاده از باتن در اندروید استودیو

    دوستان همه کدا رو نوشتم که کار براتون راحت بشه. یک جوابم رو بده ممنون میشم.

  4. #4

    نقل قول: مشکل در رفتن از اکتیویتی اول به اکتیویتی دوم به استفاده از باتن در اندروید استودیو

    کسی نیست جوابم رو بده؟

  5. #5

    نقل قول: مشکل در رفتن از اکتیویتی اول به اکتیویتی دوم به استفاده از باتن در اندروید استودیو

    دوستان خواهش می کنم یکی جواب بده!!!!

  6. #6
    کاربر جدید
    تاریخ عضویت
    دی 1396
    محل زندگی
    خراسان شمالی
    پست
    14

    نقل قول: مشکل در رفتن از اکتیویتی اول به اکتیویتی دوم به استفاده از باتن در اندروید استودیو

    دوست گرامی شما موقع تعریف Intent اینطوری باید می نوشتید :
    Intent i=new Intent(
    ContentActivity.this , Activity2.class);
    startActivity(i);

  7. #7

    نقل قول: مشکل در رفتن از اکتیویتی اول به اکتیویتی دوم به استفاده از باتن در اندروید استودیو

    باید کد Intent را درون Button کلیک بنویسی و Intent هم اشتباه است
    Button btn =(Button) findViewById(R.id.BtnVorood);
    btn.setOnClickListener(listnr);
    }

    Intent i=new Intent(ContentActivity.this , Activity2.class);
    startActivity(i)
    {

تاپیک های مشابه

  1. مشکل چپ چین بودن عبارات فارسی در اندروید استودیو
    نوشته شده توسط اندرویدی در بخش Android Studio
    پاسخ: 1
    آخرین پست: سه شنبه 07 بهمن 1393, 16:26 عصر
  2. مشکل در Full Screen کردن نرم افزار در اندروید استودیو
    نوشته شده توسط doost_fu در بخش Android Studio
    پاسخ: 2
    آخرین پست: جمعه 26 دی 1393, 19:36 عصر
  3. مشکل دیتابیس در اندروید استودیو
    نوشته شده توسط o0o0okay در بخش Android Studio
    پاسخ: 9
    آخرین پست: سه شنبه 13 آبان 1393, 11:31 صبح
  4. مشکل در اندروید استدیو
    نوشته شده توسط jalal.mehr در بخش Android Studio
    پاسخ: 7
    آخرین پست: شنبه 27 اردیبهشت 1393, 00:31 صبح
  5. سوال: مشکل در ویژوال استودیو
    نوشته شده توسط mortezahei در بخش برنامه نویسی با زبان C و ++C
    پاسخ: 2
    آخرین پست: جمعه 18 اسفند 1391, 20:43 عصر

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •