我想显示用户大部分时间单击的主页的四个按钮顶部

时间:2019-05-02 10:28:12

标签: android android-webview

我正在制作一个Web View应用程序。每个视图或按钮会将用户带到不同的网页。我想显示用户点击次数最多的4个views or按钮that user clicks most of the time separately on top of the main activity (like最喜欢的按钮or最喜欢的网页. What is the best way to save the number of user clicks on a single button? How to set those 4 particular视图or按钮on top of the screen. How to get top 4的时间?

int textResId, imageResId;
 int maxClick;
int[] clickCounter = new int[]{ 
  fbClick, instgramClick, twitterClick, snapChatClick };

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    fb = findViewById(R.id.Layout_facebook);
    fb.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            fbClick = fbClick + 1;
            String fb_url = getString(R.string.fb_url);
            Intent fb_intent = new Intent(MainActivity.this, Details.class);
            fb_intent.putExtra("url", fb_url);
            startActivity(fb_intent);
        }
    });
}

public void getMaxClick() {
    int i;
    maxClick = clickCounter[0];
    for (i = 0; i <= clickCounter.length; i++) {
        if (maxClick < clickCounter[i]) {
            maxClick = clickCounter[i];
        }
    }
}

public void getData(int maxClick) {
    if (maxClick == fbClick) {
        textResId = R.string.facebook;
        imageResId = R.drawable.ic_fb;
    }
    if (maxClick == instgramClick) {
        textResId = R.string.instagram;
        imageResId = R.drawable.ic_instagram__12;
    }

}

public View getMostUsedViews() {
    LayoutInflater layoutInflater = getLayoutInflater();
    View view = layoutInflater.inflate(R.layout.most_used, null, false);
    TextView textView = findViewById(R.id.mostUsed_Text);
    ImageView imageView = findViewById(R.id.mostUsed_Image);
    textView.setText(textResId);
    imageView.setImageResource(imageResId);
    return view;
}

} `

0 个答案:

没有答案