@Click不工作android注释

时间:2016-10-17 08:09:31

标签: android

我正在尝试使用android注释。首先在@Click中声明的所有方法都没有被突出显示虽然我在XML中声明。早期它现在突出显示它不是。当它被高亮时,那么也是Toast功能没有用。请帮助我

        <LinearLayout
        android:id="@+id/lLayout"
        android:clickable="true"
        android:onClick="openProfile"
        android:layout_width="match_parent"
        android:layout_height="75dp"
        android:orientation="vertical"
        android:layout_gravity="bottom"
        android:gravity="center|left"
        android:paddingLeft="20dp">

爪哇

package com.rsdc.tinder;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.UiThread;
import android.util.Log;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.mindorks.placeholderview.SwipePlaceHolderView;
import com.mindorks.placeholderview.annotations.Click;
import com.mindorks.placeholderview.annotations.Layout;
import com.mindorks.placeholderview.annotations.Resolve;
import com.mindorks.placeholderview.annotations.View;
import com.mindorks.placeholderview.annotations.swipe.SwipeCancelState;
import com.mindorks.placeholderview.annotations.swipe.SwipeIn;
import com.mindorks.placeholderview.annotations.swipe.SwipeInState;
import com.mindorks.placeholderview.annotations.swipe.SwipeOut;
import com.mindorks.placeholderview.annotations.swipe.SwipeOutState;

/ **  *由ADMIN于2016年10月14日创建。  * /

@Layout(R.layout.tinder_card_view)

公共类TinderCard扩展了Activity {

@View(R.id.profileImageView)
private ImageView profileImageView;

@View(R.id.nameAgeTxt)
private TextView nameAgeTxt;

@View(R.id.locationNameTxt)
private TextView locationNameTxt;

@View(R.id.user_index)
private TextView userindex;


@Click(R.id.lLayout)
void openProfile()
{

}


private Profile mProfile;
private Context mContext;
private SwipePlaceHolderView mSwipeView;

public TinderCard(Context context, Profile profile, SwipePlaceHolderView swipeView) {
    mContext = context;
    mProfile = profile;
    mSwipeView = swipeView;
}

@Resolve
private void onResolved(){
    Glide.with(mContext).load(mProfile.getImageUrl()).into(profileImageView);
    nameAgeTxt.setText(mProfile.getName() + ", " + mProfile.getAge()+"," +mProfile.getId());
    locationNameTxt.setText(mProfile.getLocation());

}

@SwipeOut
private void onSwipedOut(){
    Log.d("EVENT", "onSwipedOut");
    mSwipeView.addView(this);
}

@SwipeCancelState
private void onSwipeCancelState(){
    Log.d("EVENT", "onSwipeCancelState");
}

@SwipeIn
private void onSwipeIn(){
    Log.d("EVENT", "onSwipedIn");
}

@SwipeInState
private void onSwipeInState(){
    Log.d("EVENT", "onSwipeInState");
}

@SwipeOutState
private void onSwipeOutState(){
    Log.d("EVENT", "onSwipeOutState");
}

}

1 个答案:

答案 0 :(得分:0)

只需从xml中移除android:onClick="openProfile"即可。