0

別のプロジェクトからいくつかの Java ファイルと XML ファイルをコピーしました (レイアウトは友人が作成しましたが、コア コーディングは私が行い、別のプロジェクトで行います)。

どういうわけか、コードにレイアウトを実装するとエラーが発生します(クラスをインスタンス化できませんでした)。すべてのパッケージパスを修正し、更新してクリーンアップし、コンストラクターが公開されていることを確認しました(明らかに)が、XML は引き続き表示されます私にエラー。

Eclipse を再起動した後、プロジェクトは何とかうまく動作し、logcat でエラーもエラーも発生せずに実行されますが、Eclipse ファイルで friend_schedule.xml ファイルをチェックするとエラーが発生し続けますが、それでも好奇心をそそります。後で何らかの影響を与えるでしょう、何か考えはありますか?

インスタンス化できないJavaファイルは次のとおりです。

package cal.endar;
public class FriendSchedule extends LinearLayout 
{
public FriendSchedule(Context con)
{
    super(con);
    initComponent(con);
}

public FriendSchedule(Context con, AttributeSet att)
{
    super(con, att);
    initComponent(con);
}

public void initComponent(Context con)
{
    LayoutInflater inf=LayoutInflater.from(con);
    View v=inf.inflate(R.layout.main, null,false);

    //View v=inf.inflate(R.layout.daily_layout, null,false);
    //View v=inf.inflate(R.layout.weekly_layout, null,false);
    addView(v);
    v.getLayoutParams().height=LayoutParams.MATCH_PARENT;
    LinearLayout.LayoutParams lp=(LinearLayout.LayoutParams) v.getLayoutParams();
    lp.weight=1;
}

public void onClick(View v)
{
    v.setBackgroundResource(R.drawable.app_list_selected);
}
}

そして、これは私の friend_schedule.xml です:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="5dp">

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="45dp"
        android:layout_height="45dp"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_marginLeft="5dp"
        android:layout_weight="0.13"
        android:gravity="left|center"
        android:text="My Name"
        android:textAppearance="?android:attr/textAppearanceLarge" />
 </LinearLayout>

<cal.endar.FriendSchedule
    android:layout_width="match_parent"
    android:layout_height="match_parent" android:layout_weight="1"/>

</LinearLayout>
4

1 に答える 1

0

私はEclipseをもう一度再起動し、プロジェクトはエラーなしでうまく実行できました(なぜこれが起こったのかわかりません。これに対する適切な回答がありません)

とにかく、あなたの応答に感謝します...

于 2012-04-28T03:55:19.273 に答える