title: android.view.View cannot be cast to android.support.v7.widget.RecyclerView
body: <p>I'm following this tutorial <code>http://javatechig.com/android/android-recyclerview-example</code></p>
  
  <p>while after done coding, i'm getting one error android.view.View cannot be cast to android.support.v7.widget.RecyclerView. thanks in advance</p>
  
  <p>My MainActivity.java </p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
      private static final String TAG = "RecyclerViewExample";
      private List&lt;FeedItem&gt; feedsList;
      private RecyclerView mRecyclerView;
      private MyRecyclerAdapter adapter;
      private ProgressBar progressBar;
  
          @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          // Initialize recycler view
          mRecyclerView = (RecyclerView) findViewById(R.id.recyclerd_view);
          mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
  
          progressBar = (ProgressBar) findViewById(R.id.progress_bar);
          progressBar.setVisibility(View.VISIBLE);
  
          // Downloading data from below url
          final String url = "http://javatechig.com/?json=get_recent_posts&amp;count=45";
          new AsyncHttpTask().execute(url);
      }
  
      public class AsyncHttpTask extends AsyncTask&lt;String, Void, Integer&gt; {
  
          @Override
          protected void onPreExecute() {
              setProgressBarIndeterminateVisibility(true);
          }
  
          @Override
          protected Integer doInBackground(String... params) {
              Integer result = 0;
              HttpURLConnection urlConnection;
              try {
                  URL url = new URL(params[0]);
                  urlConnection = (HttpURLConnection) url.openConnection();
                  int statusCode = urlConnection.getResponseCode();
  
                  // 200 represents HTTP OK
                  if (statusCode == 200) {
                      BufferedReader r = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
                      StringBuilder response = new StringBuilder();
                      String line;
                      while ((line = r.readLine()) != null) {
                          response.append(line);
                      }
                      parseResult(response.toString());
                      result = 1; // Successful
                  } else {
                      result = 0; //"Failed to fetch data!";
                  }
              } catch (Exception e) {
                  Log.d(TAG, e.getLocalizedMessage());
              }
              return result; //"Failed to fetch data!";
          }
  
          @Override
          protected void onPostExecute(Integer result) {
              // Download complete. Let us update UI
              progressBar.setVisibility(View.GONE);
  
              if (result == 1) {
                  adapter = new MyRecyclerAdapter(MainActivity.this, feedsList);
                  mRecyclerView.setAdapter(adapter);
              } else {
                  Toast.makeText(MainActivity.this, "Failed to fetch data!", Toast.LENGTH_SHORT).show();
              }
          }
      }
  
      private void parseResult(String result) {
          try {
              JSONObject response = new JSONObject(result);
              JSONArray posts = response.optJSONArray("posts");
              feedsList = new ArrayList&lt;&gt;();
  
              for (int i = 0; i &lt; posts.length(); i++) {
                  JSONObject post = posts.optJSONObject(i);
                  FeedItem item = new FeedItem();
                  item.setTitle(post.optString("title"));
                  item.setThumbnail(post.optString("thumbnail"));
  
                  feedsList.add(item);
              }
          } catch (JSONException e) {
              e.printStackTrace();
          }
      }
  } 
  </code></pre>
  
  <p>activity_main.xml</p>
  
  <pre><code> &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      xmlns:class="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      android:id="@+id/relativ"
      tools:context="com.example.ict4.recyclerviewasyntask.MainActivity"&gt;
  
   &lt;View
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:id="@+id/recyclerd_view"
       android:layout_centerInParent="true"
       class="android.support.v7.widget.RecyclerView"/&gt;
      &lt;ProgressBar
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:id="@+id/progress_bar"
          android:layout_centerInParent="true"
          /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>